Im making a firebase application, inside my application, i have a listener for commentaries in a post, this is a subcollection of the document post
firebase.firestore().collection('posts').doc(post.id).collection('commentaries').orderBy('date', 'desc').limit(12)
.onSnapshot(function (querySnapshot) {
let commentaries = []
console.log(querySnapshot.docChanges())
querySnapshot.forEach(function (doc) {
commentaries.push({
id: doc.id,
creatorId: doc.data().creatorId,
commentarie: doc.data().comment,
creatorPhoto: doc.data().creatorPhoto,
creatorName: doc.data().creatorName,
date: doc.data().date
})
})
})
The problem is:
My onSnapshot is being called from OTHER USER! If other users comments on OTHER POSTS (not the post.id), onSnapshot is being called (as it would detecting changes in the root collection 'posts' and not the subcollection).
Is something wrong? My user is getting updating from all changes in collection 'posts'!!!