2

I'm new in NoSQL so I don't know if my question is possible, there is my problem. I have a List of DocumentReference (or ID) and I would like to make a query on firestore in order to get all the documents in one request.

I manage to do it with a forloop but it's reading a lot my firestore... And I don't know if take all the documents of the collection and filter the List is good practice.

I use flutter and the cloud_firestore(0.8.2) plugin.

Kyshio
  • 55
  • 4
  • Possible duplicate of [Cloud Firestore: Filter based on object content (via Flutter)](https://stackoverflow.com/questions/49543711/cloud-firestore-filter-based-on-object-content-via-flutter) – vahdet Feb 25 '19 at 07:55
  • You could use Transaction to query multiple documents. However each document would still be a read count. Also grabbing all documents then filtering it will cost you more unnecessary reads. I believe there's no official function to input an array of doc IDs to query. And I think using a loop would work fine but make sure to run it in a transaction. Also, if your list just contains small information, it's good practice to store each list item as a whole object instead of just doc Id reference. This would be cost efficient. – oliverbytes Feb 25 '19 at 07:59
  • @vahdet - It's not exactly the same problem, but it can give me idea. – Kyshio Feb 25 '19 at 08:18
  • @nemoryoliver I think I will keep the forloop then. Thank you guys – Kyshio Feb 25 '19 at 08:20

1 Answers1

-2
 Here you can use this code to get all the document in Firestore.   

Firestore _myStore = Firestore.instance;

        _myStore.collection('users').document('${user.uid}').setData({
                    "Email": _emailAddress.text.toLowerCase(),
                    "Name": _userName.text,
                    'Role': 'user',
                    'Created': FieldValue.serverTimestamp(),
                  });
Neha Bhardwaj
  • 1,275
  • 10
  • 13