【问题标题】:Firestore recursive batched delete [duplicate]Firestore递归批量删除[重复]
【发布时间】:2021-10-04 17:46:12
【问题描述】:

我正在使用批处理操作删除包含子集合的文档。

const myDocRef = firestore.collection("...").doc("...");
const myOtherDocRef = firestore.collection("...").doc("...");

const batch = firestore.batch();

batch.delete(myDocRef);
batch.delete(myOtherDocRef);
// TODO - Delete sub-collections ("likes", "comments")

batch.commit();

文档“myOtherDoc”是具有嵌套子集合的文档。如何使用批处理操作递归地删除它们?

我的意思是,不能为递归删除添加一些配置吗?

【问题讨论】:

    标签: node.js firebase google-cloud-firestore


    【解决方案1】:

    文档中有关于递归删除集合的详细说明。您可以从中复制代码并在云函数中运行。

    您可以利用 Firebase 命令行界面 (CLI) 中的 firestore:delete 命令,而不是为您的 Cloud Function 实现自己的递归删除逻辑。您可以使用 firebase-tools 包将 Firebase CLI 的任何功能导入您的 Node.js 应用程序。

    参考:https://firebase.google.com/docs/firestore/solutions/delete-collections#cloud_function

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-12
      • 2022-01-26
      • 2023-01-30
      • 2021-05-06
      • 1970-01-01
      • 2017-08-22
      • 1970-01-01
      • 2015-01-05
      相关资源
      最近更新 更多