0

For the example enter image description here

I want to get the age field of all documents. At the moment, I am using:

await collection.get().then((value) {
      for (QueryDocumentSnapshot doc in value.docs) {
        print(doc.get('age'));
      }
    });

This method gets all fields of the document and then get specific field by using .get('age'). I don't want to get big data and then filter it. The firebase has the .doc('') function to get specific documents but I don't found something like .field(['']) to get these fields that I want.

Is it possible to get the specific fields that I selected?

  • This is not possible with the client SDK atm. You would have to fetch data through a Cloud Function to get send specific data only to client or denormalize the data. Checkout the linked answer for more information. – Dharmaraj Oct 01 '22 at 05:03
  • Hi, thank you for the fact. This helps me decide to separate this field into the new collection. – Sittiphan Sittisak Oct 01 '22 at 05:24

0 Answers0