0

There is a database named userdetails of three columns name, email, and password. How can I fetch only name from Firebase Firestore? Please give an example.

I have stucked in that thing(fetching of specific data)

Arindam
  • 51
  • 2
  • 6
  • In server-side environments you can use `select` for that. In client-side SDKs, that option doens't exist and you always get the full document. – Frank van Puffelen Feb 15 '23 at 14:57

1 Answers1

1

As far as I am aware, you can't do that with a server side query. A firebase query would return the DocumentSnapshot.

On the client side you would map that to what you need.

https://firebase.google.com/docs/firestore/query-data/get-data

  • Can you elaborate with an example? – Arindam Feb 15 '23 at 16:20
  • A good example is under the custom objects section of the above link. https://firebase.google.com/docs/firestore/query-data/get-data#custom_objects. Essentially convert the returned document to a map and access the fields needed through that. – Ronan Hughes Feb 15 '23 at 22:50