Skip to main content
Best answer

How do I write a Firestore query to select a single record by Doc ID?

  • August 15, 2023
  • 2 replies
  • 292 views

Forum|alt.badge.img

Hi, I´m looking for an example of a firestore query to select a single record.  I know the doc ID I want to select.

Please only real examples, and no suggestions to read the documentation - its “poor” (being really polite).  

 


"where": { "fieldFilter": { "field": { "fieldPath": "__name__" }, "op": "EQUAL", "value": { "referenceValue": "projects/adventure-hunt-323xxx/databases/(default)/documents/CollectionName/xxxxxxxxxxx } } },

 

xxxxxxxxxxxx is the value I want to search for.

Best answer by Tenerifekiwi

Solved.  By removing the orderby part of the query it worked fine.

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Forum|alt.badge.img
  • Author
  • Beginner
  • Answer
  • August 15, 2023

Solved.  By removing the orderby part of the query it worked fine.


SamB
Community Manager
Forum|alt.badge.img+11
  • Community Manager
  • August 16, 2023

Thanks so much for circling back to share your solution here, @Tenerifekiwi! I’m sure it’ll be helpful to a lot of folks in Community that might be facing the same issue. 🤗