简体   繁体   English

使用 Flutter 更新 Firestore 中的项目

[英]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 结构

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.

相关问题 StreamBuilder 未更新 Flutter 中的 Firestore 数据 - StreamBuilder not updating Firestore data in Flutter Firestore 数据库未更新(颤振/飞镖) - Firestore Database not updating (flutter/dart) 使用 Flutter 和 Firestore 中的新数据更新 StreamBuilder - Updating a StreamBuilder with new data in Flutter and Firestore 使用 Flutter 更新图像时,更新 Cloud Firestore 中对图像 url 的所有引用 - Updating all the references to an image url in Cloud Firestore when the image is updated using Flutter 如何使用 Flutter 在 Firestore 中存储文件夹列表并且每个文件夹都有项目列表 - How can I store a list of folders and each folder has list of items in Firestore using Flutter 为什么在 Firestore Flutter 中更新数据后 DateTime 会转换为 TimeStamp? - Why DateTime is converted to TimeStamp after updating data in Firestore Flutter? 从 flutter 应用程序在 firestore 中更新数据后无法读取数据 - Cannot read data after updating it in firestore from flutter app 从 ListTile Flutter 更新 Firestore 文档 Boolean 值 - Updating Firestore Document Boolean value from ListTile Flutter Flutter:更新单个文档时,StreamBuilder 获取其他 Firestore 文档 - Flutter: StreamBuilder gets other firestore documents when updating a single document 如何使用 Firebase Firestore 中的数据填充 Flutter 中的 DropdownButtonFormField 中的项目 - How to populate items in a DropdownButtonFormField in Flutter with data in Firebase Firestore
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM