firebase - 在 firestore 中自动创建集合

标签 firebase flutter google-cloud-firestore nosql

是否可以更新此方法:

void uploadMatch(team1, team2) {
    Firestore.instance.collection("upcomings").add({
      "createdAt": Timestamp.now(),
      "upcomingTeam1": team1,
      "upcomingTeam2": team2
    });
  }

如果 comcomings 集合不存在,它会创建它吗?谢谢!

最佳答案

来自documentation :

Collections and documents are created implicitly in Cloud Firestore. Simply assign data to a document within a collection. If either the collection or document does not exist, Cloud Firestore creates it.

所以回答你的问题:这是不可能的! 集合是在您创建文档时隐式创建的,当您删除集合中的最后一个文档时,它将不复存在。

关于firebase - 在 firestore 中自动创建集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63580594/

相关文章:

image - 如何从 Assets 中为 CircleAvatar 提供图像

javascript - 如何从云功能内部运行查询?

未在 REST 服务器上验证来自 Flutter App 的 Firebase Id token

database - firebase的Blaze计划是按天计算还是按月计算?

flutter - 尝试使用 ValueNotifier 和 ValueListenable 实现极简架构时面临编译器错误

android - 应用程序打开时 Firebase 通知不显示

android - 如何使用 firestore 在回收站 View 中加载批量数据?

node.js - 在谷歌应用程序引擎上运行 firebase admin 和 firestore

node.js - DeprecationWarning : grpc. 加载,改用@grpc/proto-loader

firebase - 尝试从 React 应用程序连接到 firebase 函数 - 有问题吗?