I am creating an app where people can read messages and in firestore, once they have read a message it adds the user's uid (who read it) to the specific doc, like so:
hasread
userId -> uid
What I am trying to do, is count the amount of docs that do not have the user's uid and return that number.
const usrId = firebase.auth().currentUser.uid;
const countNewAnnounce = this.announce
.where('hasread.userId', '!=', usrId)
.get()
.then(snapshot => {
console.log('size', snapshot.size);
})
.catch(err => {
console.log('Error getting documents', err);
});
The snapshot.size will always return the total amount of docs, so somehow the where is not working correctly or I am not using it correctly (probably the last).