本文档不存在,不会显示在查询或快照中,但具有相同结构的文档工作 [英] This document does not exist and will not appear in queries or snapshots, but identically structured document works

查看:170
本文介绍了本文档不存在,不会显示在查询或快照中,但具有相同结构的文档工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前言:这个问题已经被问到

解决方案

c> territories / 6 不是作为实际的文件存在,而是 territories / 7 没有。



在Cloud Firestore中,可以拥有虚拟文档所拥有的子集合 - 即不存在较高级别的文档,但具有子元素。



这些虚拟文件可以很容易地组织信息,而不必创建重复的虚拟文件。



在这种情况下,您可以:



  1. 之前,在 territories / 6 下创建了一堆发送文档, c $ c>地区文档或
  2. 您随后删除了地区/ 6 子收集文件。
  3. >


Preface: this question is already asked here but user gave up and gave solution to first answer. This question also differs in that I have two similar collection structures, but the error only occurs on one of them.

I am working with Google's new firestore database, and have created the following structure: territories/{list of territories}/dispatches/{list of dispatches}/{dispatch information}

We are using this method to create custom tokens on our backend using Firebase Admin SDK. When a user logs in on our backend, we generate the token and add the territories they have access to as additional claims, which we intend to access from the auth / request.auth objects in our Security Rules to limit their access to the dispatch documents accordingly. I mention this in case we are going about the structure incorrectly, in which case please correct me as we are new to firestore.

The problem we are encountering is that one of the documents gives the warning: "This document does not exist and will not appear in queries or snapshots" (see image below). However, we have an identical document structure (document 7 in the image) that does not give this warning and does appear in queries and snapshots.

解决方案

This is telling you that territories/6 does not exist as an actual document, whereas territories/7 does.

In Cloud Firestore it is possible to have subcollections owned by "virtual" documents - that is the document at the higher level doesn't exist, but it has children.

These virtual documents can be easy ways to organize information without have to create duplicate dummy documents.

In this case, you've either:

  1. Created a bunch of dispatch documents under territories/6 before you created the territories document, or
  2. You've subsequently deleted territories/6 without deleting the subcollection documents.

这篇关于本文档不存在,不会显示在查询或快照中,但具有相同结构的文档工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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