question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Firestore sub-collections with nonexistent parents are not showing in emulator

See original GitHub issue

[REQUIRED] Environment info

firebase-tools: 8.4.0

Platform: macOS 10.15.4

[REQUIRED] Test case

I’ve found that when having nested collections in Firestore, they don’t display on the web interface of the emulator unless parent documents contain data.

[REQUIRED] Steps to reproduce

// create some data in a nested collection without data in the document

db.collection('stripe')
.doc('6tSfMgrOCEOi3kj0IHRivd0ZCgX2')
.collection('subscriptions')
.doc('sub_123456789').set({
    status: "active"
})

[REQUIRED] Expected behavior

On the production version of the data viewer, it displays empty documents in italics (to designate that there is no fields but sub-collections exist). Image below. Screen Shot 2020-05-24 at 8 02 36 PM

[REQUIRED] Actual behavior

There is nothing to display on the UI and I cannot access child collections. If I set some dummy data on a document, the row will appear.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:32
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
yuchenshicommented, Jul 6, 2020

I’ve escalated this internally as b/152785133 and we’re actively trying to staff this fix. In the meantime, feel free to send us a Pull Request.

4reactions
4mitabhcommented, Jun 6, 2020

This is not merely an emulator UI issue.

In certain cases, the behavior of writes is different between emulators and production.

Steps to reproduce:

Perform the following write operation, on em empty database.

db.collection('one')
.doc('two')
.collection('three')
.doc('four').set({
    status: "active"
})

Expected behavior

  1. An empty document 'two., with a collection ‘three’ is created. This works perfectly in production.
  2. Reads to path “/one/two” should succeed .

Actual behavior:

  1. Document ‘two’ is not created in the emulated database.
  2. Reads to path “/one/two” fail. Document.exists returns false.
Read more comments on GitHub >

github_iconTop Results From Across the Web

This document does not exist and will not appear in queries or ...
In Cloud Firestore it is possible to have subcollections owned by "virtual" documents - that is the document at the higher level doesn't...
Read more >
Cloud Firestore Data model - Firebase
Collections and documents are created implicitly in Cloud Firestore. Simply assign data to a document within a collection. If either the collection or...
Read more >
Create a Firestore subcollection reference - Google Cloud
Create a Firestore subcollection reference. bookmark_border. Stay organized with collections Save and categorize content based on your preferences. Dismiss
Read more >
How to read your entire dataset in Firestore - Medium
We can see my two root-collections: chatrooms and users. It shows the three chatrooms documents, even through chatrooms/flash does not exist ( ...
Read more >
Getting Started With Cloud Firestore for Android - Code
A subcollection is just a collection that belongs to a document. By default, a document automatically becomes the parent of all the documents ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found