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

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

问题描述

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

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天全站免登陆