I want to query certain data and update the query result in a batch.
If I use this format from this example,
let ref = db.collection("cities").whereField("sellerUserId", isEqualTo: userId)
db.runTransaction({ (transaction, errorPointer) -> Any? in
let document: DocumentSnapshot
do {
try document = transaction.getDocument(ref) <-- error
} catch let fetchError as NSError {
errorPointer?.pointee = fetchError
return nil
}
// more code
})
I get this error:
Cannot convert value of type "Query" to expected argument type "DocumentReference"
I get the same error with the batch writes:
let batch = db.batch()
let ref = db.collection("cities")
.whereField("sellerUserId", isEqualTo: userId)
batch.updateData(["population": 1000000 ], forDocument: ref)
Is there any way to batch update the query result without iterating over individual document?