There is a collection users
and inside user there is a document userID
and inside this document there is another collection favourite
and inside this collection , there is id’s of saved favourite data favouriteId
.
So i want to delete that data inside favourite
colletion.
My db look likes:-
users(collection)>userID(document)>favourite(collection)>favouriteId(document)
Here is my code for that:
const deleteDoc = async (id) => {
const userRef = collection(db, "users");
const favRef = collection(
userRef,
`${firebaseAuth?.currentUser?.uid}/favourite`
);
const favId = doc(favRef, id);
await deleteDoc(favId);
};
favouriteId=id ,
userId=firebaseAuth?.currentUser?.uid
I use firebase v9.
2
Answers
your code is Most of correct you just need some changings in code like that
You are naming your function in the same way as the Firebase function.
Just change the function name