[英]Updating items in Firestore using Flutter
I am making a friend req type Functionality So if I tap on add friend button the name of Current Logged in person should be added to the request list of person named I searched.我正在交一个朋友请求类型功能因此,如果我点击添加朋友按钮,当前登录的人的名字应该添加到我搜索的名字的人的请求列表中。
So from my app when I click on add friend button, let say current logged in user is 'c@c.com' and I search for 'd@d.com' then 'c@c.com' user name should be added in the requests array of the person 'd@d.com'.因此,当我单击“添加朋友”按钮时,从我的应用程序中,假设当前登录用户是“c@c.com”,我搜索“d@d.com”,然后应添加“c@c.com”用户名在“d@d.com”这个人的请求数组中。
This is my search method to search a user这是我搜索用户的搜索方法
void onSearch() async {
await _firestore
.collection("users")
.where("email", isEqualTo: _search.text)
.get()
.then((value) {
setState(() {
userMap = value.docs[0].data();
});
});
}
What should I write in addUser method?我应该在 addUser 方法中写什么?
void addUser() async {
await _firestore
.collection("users")
.where("email", isEqualTo: _search.text)
.get()
;
}
To learn how to add items to and remove items from an array, see the Firebase documentation on updating an array .要了解如何向数组添加项和从数组中删除项,请参阅有关更新数组的 Firebase 文档。 To learn how to update all documents that match a query, see How to get the document ref to a where clause firestore?
要了解如何更新与查询匹配的所有文档,请参阅如何将文档引用获取到 where 子句 firestore?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.