'How do I changed this Firebase version 8 syntax to version 9?
This is the syntax I originally used to add a document to a subcollection "posts". But I think it is not supported by firebase version 9
const unsubscribe = db.collection("users").doc(firebase.auth().currentUser.email).collection("posts").add({
imageUrl: currentLoggedInUser.unsername,
user: CurrentLoggedInUser.username,
profile_picture: CurrentLoggedInUser.profilePicture,
owner_uid: auth.currentUser.uid,
caption: caption,
createdAt: serverTimestamp(),
likes: 0,
likes_by_users: [],
comments: [],
}).then(() => navigation.navigate('HomeScreen'))
return unsubscribe
What I tried
const unsubscribe = (doc(collection(db, "users")), auth.currentUser.email, addDoc(collection("posts"), {
imageUrl: imageUrl,
user: CurrentLoggedInUser.username,
profile_picture: CurrentLoggedInUser.profilePicture,
owner_uid: auth.currentUser.uid,
caption: caption,
createdAt: serverTimestamp(),
likes: 0,
likes_by_users: [],
comments: [],
}).then(() => navigation.navigate('HomeScreen'))
return unsubscribe
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
