父文档被标记为“已删除".(斜体)默认情况下 [英] Parent document is being marked as "deleted" (italics) by default

查看:46
本文介绍了父文档被标记为“已删除".(斜体)默认情况下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个奇怪的问题,即我们的父文档被标记为已删除.我正在插入这样的新文档:

I am having a weird issue where our parent document is being marked as deleted. I am inserting a new document like this:

const userDoc = admin.firestore().doc(`/user_bundles/${context.params.userId}/bundles/${chargeRecord.course_id}/media/${chargeRecord.media_type}`);
return userDoc.set(bundleDoc.data(), { merge: true });

但是,"chargeRecord.course_id"文档被标记为已删除,导致空查询.

However, the "chargeRecord.course_id" document is being marked as deleted, resulting in empty queries.

我遇到了另一个问题和答案,它解释了删除子集合时可能发生的情况.但需要明确的是,我们尚未删除此文档.它是为用户新创建的.

I've ran into another question and answer where it explained this can happen when the sub collection is deleted. But to be clear we have not deleted this document. It was newly created for the user.

推荐答案

文档和子集合不能像文件系统文件和目录那样工作.

创建根据文档ID组织的子集合不会隐式创建任何父文档.子集合不以任何方式绑定到父文档,除非通过您强加的组织.在不存在的文档ID下组织子集合是完全有效的.

Creating a subcollection organized under a document ID doesn't implicitly create any parent documents. Subcollections are not tied in any way to a parent document, other than through the organization you impose. It's perfectly valid to organize subcollection under a document id that doesn't exist.

以斜体显示的文档ID不必删除".之所以显示它们,是因为它们不存在,甚至可能不存在-您无法分辨出差异.

Document IDs shown in italics are not necessarily "deleted". They are shown that way because the don't exist, and maybe never existed - you can't tell the difference.

如果要存在任何文档,则必须编写一些代码来创建它并提供一些字段.如果您从未明确创建文档,则该文档将不存在.

If you want any document to exist, you have to write some code to create it and give it some fields. If you never explicitly create a document, then it never exists.

如果删除文档,则其子集合仍然存在.

If you delete a document, its subcollections still exist.

这篇关于父文档被标记为“已删除".(斜体)默认情况下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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