Firestore returns a document even though none exists

popClingwrap

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

Doug Stevenson

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Python dict.get(k) returns none even though key exists

From Dev

dlsym returns NULL, even though the symbol exists

From Dev

TryGetValue returns false even though the key exists

From Dev

Why getmethod returns null even though the method exists

From Dev

MySQL select for update returns empty set even though a row exists

From Dev

Returns undefined on a object prop even though it exists-JS

From Dev

Property returns undefined even though the value exists...?

From Java

Seekbar is null, even though it exists

From Dev

FileNotFoundException even though file exists

From Dev

Downloading AWS S3 file with python boto returns 404 even though file exists

From Dev

RealmCollectionChange reports modifications even though there's none

From Dev

Facebook KeyNotFoundException Even Though the Key Exists

From Dev

Laravel FileNotFoundException thrown even though file exists

From Dev

Java NoClassDefFoundError even though the class exists

From Dev

"bash: No such file or directory" even though file exists

From Dev

Telegram webhook not found even though it exists

From Dev

SCOOP ERROR of database name does not exists even though it exists

From Dev

AXIsProcessTrustedWithOptions returns NO even though the app is on the whitelist

From Dev

peekService returns null even though startService does not

From Dev

C - regexec returns NOMATCH - even though it should?

From Dev

hasNext() returns false, even though the file is not empty

From Dev

Document.toString() is "[#document: null]" even though XML was parsed

From Java

Scala isDefined gets None value even though it has values

From Dev

Link is still underlined even though text-decoration is set to none

From Dev

Why this class variable is None even though it has been initialized?

From Dev

Popen.communicate() returns (None, None) even if script print results

From Dev

Type.GetType fails even though class exists

From Dev

"undefined method `deleted_at=' for #<Spree::User", even though this column exists

From Java

Flask raises TemplateNotFound error even though template file exists

Related Related

  1. 1

    Python dict.get(k) returns none even though key exists

  2. 2

    dlsym returns NULL, even though the symbol exists

  3. 3

    TryGetValue returns false even though the key exists

  4. 4

    Why getmethod returns null even though the method exists

  5. 5

    MySQL select for update returns empty set even though a row exists

  6. 6

    Returns undefined on a object prop even though it exists-JS

  7. 7

    Property returns undefined even though the value exists...?

  8. 8

    Seekbar is null, even though it exists

  9. 9

    FileNotFoundException even though file exists

  10. 10

    Downloading AWS S3 file with python boto returns 404 even though file exists

  11. 11

    RealmCollectionChange reports modifications even though there's none

  12. 12

    Facebook KeyNotFoundException Even Though the Key Exists

  13. 13

    Laravel FileNotFoundException thrown even though file exists

  14. 14

    Java NoClassDefFoundError even though the class exists

  15. 15

    "bash: No such file or directory" even though file exists

  16. 16

    Telegram webhook not found even though it exists

  17. 17

    SCOOP ERROR of database name does not exists even though it exists

  18. 18

    AXIsProcessTrustedWithOptions returns NO even though the app is on the whitelist

  19. 19

    peekService returns null even though startService does not

  20. 20

    C - regexec returns NOMATCH - even though it should?

  21. 21

    hasNext() returns false, even though the file is not empty

  22. 22

    Document.toString() is "[#document: null]" even though XML was parsed

  23. 23

    Scala isDefined gets None value even though it has values

  24. 24

    Link is still underlined even though text-decoration is set to none

  25. 25

    Why this class variable is None even though it has been initialized?

  26. 26

    Popen.communicate() returns (None, None) even if script print results

  27. 27

    Type.GetType fails even though class exists

  28. 28

    "undefined method `deleted_at=' for #<Spree::User", even though this column exists

  29. 29

    Flask raises TemplateNotFound error even though template file exists

HotTag

Archive