Firestore使用Java删除特定文档

发布于 2025-02-11 06:01:46 字数 383 浏览 1 评论 0原文

连接到firestore数据库

Query query = dbFirestore.collection("collectionName").whereEqualTo("columnName ==",XXX);
ApiFuture<QuerySnapshot> apiFutureResults = query.get();

使用以下代码, apifuture,apifutureresults.get() ?如何从此处删除文档列表。在我的情况下,它只有一个文档用于给定条件。我没有在 apifutureresults 下看到任何删除函数。

fyi。这是纯Java应用。没有android。所以请不要听众。

Connected to the Firestore database using below code,

Query query = dbFirestore.collection("collectionName").whereEqualTo("columnName ==",XXX);
ApiFuture<QuerySnapshot> apiFutureResults = query.get();

From ApiFuture, apiFutureResults.get() ? How to delete the list of documents one by one from here. In my case its only one document for the given condition. I don't see any delete function underneath apiFutureResults .

FYI. This is pure Java Application. No Android. So No listeners please.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

涫野音 2025-02-18 06:01:46

要逐一删除文档列表,您可以使用以下示例中使用delete()函数:

// [START firestore_data_delete_doc]
// asynchronously delete a document

ApiFuture<WriteResult> writeResult = db.collection("cities").document("DC").delete();

// ...

System.out.println("Update time : " + writeResult.get().getUpdateTime());

// [END firestore_data_delete_doc]

重要的是要注意,当您删除文档时,Cloud Firestore不会在其子策略中自动删除文档。通过参考,您仍然可以访问子集合中的论文。

必须删除文档手动任何子集合中包含的文档。

To delete the list of documents one by one, you can use the delete() function as in the following example:

// [START firestore_data_delete_doc]
// asynchronously delete a document

ApiFuture<WriteResult> writeResult = db.collection("cities").document("DC").delete();

// ...

System.out.println("Update time : " + writeResult.get().getUpdateTime());

// [END firestore_data_delete_doc]

It is important to note that Cloud Firestore does not automatically remove the documents in its subcollections when you delete a document. By reference, you can still access the papers in the subcollection.

A document must be deleted manually along with all of the documents contained in any subcollections.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文