我試圖恢復一個檔案,它的欄位“電子郵件”等于某個值我的代碼沒有給我任何東西不知道是什么問題
void EditDisplayedName(String email, String name) async {
CollectionReference s = FirebaseFirestore.instance
.collection("Users")
.doc("list_instructors")
.collection("Instructor")
..where("Email", isEqualTo: email);
s.doc(email).update({'Full Name': name});
} //end method
uj5u.com熱心網友回復:
您的代碼尚未找到/閱讀電子郵件地址的檔案。
正確的流程是:
// 1. Create a reference to the collection
CollectionReference s = FirebaseFirestore.instance
.collection("Users")
.doc("list_instructors")
.collection("Instructor")
// 2. Create a query for the user with the given email address
Query query = s.where("Email", isEqualTo: email);
// 3. Execute the query to get the documents
QuerySnapshot querySnapshot = await query.get();
// 4. Loop over the resulting document(s), since there may be multiple
querySnapshot.docs.forEach((doc) {
// 5. Update the 'Full Name' field in this document
doc.reference.update({'Full Name': name});
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/350641.html
標籤:火力基地 扑 镖 谷歌云firestore
