I set a documents key in a collection to the userId, and now I would like to get that one document in a snapshot for realtime results:
Ref = firestore().collection('Ref');
Ref.where("[.key]","==",this.id).onSnapshot(snap => {
if (!snap.empty) {
snap.docChanges().forEach(change => {
if (change.type === "modified") {
// update model here for charts
this.user = change.doc.data()
}
if (change.type === "added") {
// create a new chart
this.user = change.doc.data()
}
})
}
})
I tried key .key [.key] nothing is working. I would like to watch this one document for changes while its user is logged in.