i am trying to develop a service in my angular application that validate if a document already exist in my firestore database. How can i do that?
i have been checking the oficial documentation but i dont find the solution :S
Here is my code.
user: {
id: 'user1'
}
private usersCollection: AngularFirestoreCollection;
constructor(private _afs: AngularFirestore) {
this.usersCollection = _afs.collection('users');
this.userCollection.doc(user.id).snapshotChanges().subscribe(data => {
if(data.payload.exist){
//User exist
}else{
//User no exist
}
})
when i try this... Always returns false even if the Doc exist...
am i checking correctly if User.id exist as a document in my collection Users?
ScreenShot of my database structure
As you can see in the img, there is a document called User1, why is data.payload.exist false?