I'm using the web API, Typescript, no other libraries.
I've set up a very simple database. Users sign up with email/password and a doc is added to a /users
collection with their uid as the key. When a user logs in I check their uid against the /users
collection and return the relevant doc.
I've been messing with security rules, checking my logic and regularly manually deleting users and data via the Firebase console as I go. I don't know if something has got confused but now my database is completely empty according to the console Data tab - there is no /users
collection or anything else - but when I run...
this.db.doc(`users/${firebase.auth().currentUser.uid}`).get()
...I get a document back that has the correct id (matches my registered user id) but the exists
property is false
. Where is this coming from?
As the database is empty I'm assuming its from some kind of local cache?
Or have I confused things or got out of sync by manually deleting data?
Can I clear that cache, or do I have to do an extra check for exists:false
Cheers all
I get a document back that has the correct id (matches my registered user id) but the exists property is false. Where is this coming from?
You will always get a DocumentSnapshot for any single-document get()
. That's just the way it works. You definitely have to check the exists flag (or see that data()
returns an object) to know if there is any data in that snapshot. It's not really any more complicated than that.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments