如何在不指定文档ID的情况下更新文档内部的数据? [英] How do I update data inside documents without specifying the document ID?

查看:79
本文介绍了如何在不指定文档ID的情况下更新文档内部的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在不指定文档ID的情况下更新文档内部的数据,

Is there a way to update data inside documents without specifying the document ID,

但是在进行stackoverflow时,我看到了这段代码

But while going thorugh stackoverflow I saw this code

firebase.firestore().collection("users")
  .where("name", "==", "Daniel")
  .get(function(querySnapshot) {
    querySnapshot.forEach(function(document) {
     document.ref.update({ ... }); 
    });
  });

有人可以将其翻译为颤动代码(Dart)吗?这是一个查询,用于无需添加文档ID即可向下搜索文档搜索。我认为。

Can someone please translate this to flutter code(Dart) please. It's a query to norrow down the document search without having to put in the document ID. I think.

推荐答案

相当于您发布的代码的Dart看起来像这样:

The Dart equivalent to code you posted would look like this:

Firestore.instance.collection('users')
  .where('name', isEqualTo: 'Daniel')
  .getDocuments()
  .then((querySnapshot) {
    querySnapshot.documents.forEach((documentSnapshot) {
      documentSnapshot.reference.updateData({ ... });
    });
  });

这篇关于如何在不指定文档ID的情况下更新文档内部的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆