firestore exists code example
Example 1: firestore get all documents in collection
db.collection('documents')
.get()
.then(querySnapshot => {
const documents = querySnapshot.docs.map(doc => doc.data())
})
db.collection('documents')
.doc(documentId)
.get()
.then(snapshot => {
const document = snapshot.data()
})
Example 2: get one document based on id in firestore
const [userDetails, setUserDetails] = useState('')
db.collection('users').doc(id).get()
.then(snapshot => setUserDetails(snapshot.data()))