问题
Is there a way to update data inside documents without specifying the document ID,
But while going thorugh stackoverflow I saw this code
firebase.firestore().collection("users")
.where("name", "==", "Daniel")
.get(function(querySnapshot) {
querySnapshot.forEach(function(document) {
document.ref.update({ ... });
});
});
Can someone please translate this to flutter code(Dart) please. It's a query to norrow down the document search without having to put in the document ID. I think.
回答1:
The Dart equivalent to code you posted would look like this:
Firestore.instance.collection('users')
.where('name', isEqualTo: 'Daniel')
.getDocuments()
.then((querySnapshot) {
querySnapshot.documents.forEach((documentSnapshot) {
documentSnapshot.reference.update({ ... });
});
});
来源:https://stackoverflow.com/questions/59144744/how-do-i-update-data-inside-documents-without-specifying-the-document-id