Like upper question, i want to get value of some field in firebase firestore instead of all document with DocumentSnapshot
like this in SQL SELECT col_1, col_2, col_3 FROM table_name
How can i do it?
Thank you for the help.
There are two ways for retrieving data, which is stored in Cloud Firestore. Calling a method to get the data. Setting a listener for receiving data changes events. We send an initial snapshot of the data, and then another snapshot is sent when the document changes.
Starting with… in queries! With the in query, you can query a specific field for multiple values (up to 10) in a single query. You do this by passing a list containing all the values you want to search for, and Cloud Firestore will match any document whose field equals one of those values.
The Cloud Firestore client-side SDKs always read and returns full documents. There is no way to read a subset of the fields in a document.
You can retrieve the entire document, and then process the DocumentSnapshot
to just use the fields you're interested. But this means you're using more bandwidth than needed. If this is a regular occurrence for your app, consider creating a secondary collection where each document contains just the fields you're interested in.
Also see Doug's answer here (for Swift): How to access a specific field from Cloud FireStore Firebase in Swift
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With