Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

Firestore Structure

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’.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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()
           ;
  }

>Solution :

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?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading