Skip to content
Advertisement

How to get users document id in Firestore using Javascript?

how to get only the last document id in Firestore?

i tried

JavaScript

the result i’m getting wrong id thats not in the orders document!!

enter image description here

This is my documents :

enter image description here

Advertisement

Answer

You are running db.collection('users').doc(user.uid).collection('orders').doc() twice which creates 2 different DocumentReferences and hence they are different. If you are trying to get the document that you just added try this:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement