final batch = FirebaseFirestore.instance.batch();
var nycRef = FirebaseFirestore.instance.collection("FoodOrders").doc();
// I want to specify a field here like where()
// e.g var nycRef = FirebaseFirestore.instance.collection("FoodOrders").where("MyId",isEqualTo: myId);
batch.update(nycRef, {"Paid": true});
batch.commit();
But I get an error saying
The argument type ‘Query<Map<String, dynamic>>’ can’t be assigned to
the parameter type ‘DocumentReference<Object?>’.
Is there a way of filtering my batch write
I want to batch.update specifically where field MyId is equal to myId,how do I write it?
2
Answers
Firestore doesn’t support updating all of the documents returned by a query like you can in SQL. The only way to do what you want is to perform each of these in sequence:
try this as also described the steps by @DougStevenson .