Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

This document does not exist, it will not appear in queries or snapshots? Cloud Firestore

I'm quite new to Cloud Firestore (aren't we all?) and I've added some data to my db using the admin SDK in Node.js. It shows up on the console, but under the doc it says "This document does not exist, it will not appear in queries or snapshots." I'm not sure why this is? Here's a screenshot:enter image description here

like image 637
Neil Shweky Avatar asked Oct 19 '17 00:10

Neil Shweky


2 Answers

The key thing to realize is that just because you create a document at root_collection > root_doc > sub_collection > sub_doc does not mean there is actually a document at root_collection > root_doc.

So in order to show you the documents under ... > Events > 10-12-2017 > Phase Data, the console is showing 10-12-2017 as if it was a document, but it's letting you know that there is actually no document at that location. So if you do a query for the documents under ... > Events, 10-12-2017 will not show up.

like image 108
Michael Lehenbauer Avatar answered Oct 24 '22 04:10

Michael Lehenbauer


I think this is the answer you all are looking for: When you create a document like:

let ref = Firestore.firestore().collection("users").document().collection("data")

you aren't creating an actual location for that document with the auto-generated id. Rather, add an empty field as so:

let tempRef = Firestore.firestore().collection("users").addDocument(data: ["dummy":"text"])
let id = ref.documentId
let ref = Firestore.firestore.collection("users").document(id).collection("data")

I tried it out and works fine now.

like image 1
Rithvik Ravikumar Avatar answered Oct 24 '22 06:10

Rithvik Ravikumar