I build react native app with firebase/firestore and I get the error
Error: Argument "documentPath" must point to a document.
when I write this line
var userStatusFirestoreRef = firebase.firestore().doc('/status/' + uid);
all code
firebase.auth().signInAnonymouslyAndRetrieveData().then((user) => {
var uid = firebase.auth().currentUser.uid;
var userStatusFirestoreRef = firebase.firestore().doc('/status/' + uid);
});
You should chain the collection()
and doc()
methods for each segment of the firestore path, example:
firebase.firestore().collection('status').doc(uid)
You can chain these as far as your subcollections and subdocuments go.
firebase.firestore().collection('status').doc(uid).collection('messages').doc('messageId')
UPDATE : now you can't put a forward slash '/' in a document's name, it throws the error:
firebase.firestore().collection().doc(*) 'document path' must point a docment
I found the error, it should be
var userStatusFirestoreRef = firebase.firestore().doc('status/' + uid);
with one '/' at the end of 'status/'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With