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 '[email protected]' and I search for '[email protected]' then '[email protected]' user name should be added in the requests array of the person '[email protected]'.
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 ?
void addUser() async {
await _firestore
.collection("users")
.where("email", isEqualTo: _search.text)
.get()
;
}
CodePudding user response:
To learn how to add items to and remove items from an array, see the Firebase documentation on updating an array. To learn how to update all documents that match a query, see How to get the document ref to a where clause firestore?