i'd like to know if there's a way to query firebase firestore collection in Flutter adding more than one field to the query. I tried some ways but i didn't realize how to do that. For example:
CollectionReference col = Firestore.instance
.collection("mycollection");
col.where('nome', isEqualTo: 'Tyg');
col.where('valor', isLessThan: '39');
Someone, please, have some way to do that? i am new in flutter and not getting the way.
So to know if a Collection exists of no, you can run a query that checks for a field in Info Documents (eg CollectionInfo. exists) to know which Collections have been already created. However, please keep in mind that this will have an extra cost every extra Read/Write operation.
FlutterFire is a set of Flutter plugins which connect your Flutter application to Firebase.
A QuerySnapshot contains the results of a query. It can contain zero or more DocumentSnapshot objects. Subclassing Note: Cloud Firestore classes are not meant to be subclassed except for use in test mocks. Subclassing is not supported in production code and new SDK releases may break code that does so.
Building Firestore queries follows a "builder pattern". Every time you call where
it returns a new query object. So the code you have constructs two queries, that you don't assign to anything.
CollectionReference col = Firestore.instance
.collection("mycollection");
Query nameQuery = col.where('nome', isEqualTo: 'Tyg');
Query nameValorQuery = nameQuery.where('valor', isLessThan: '39');
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