0

I am writing a cloud function for creating a path/doc like this:

transaction.create(db.collection('collect1/doc1/collect2').doc(), {current: "simulator"})

There was no error or anything. The doc get created successfully as well as the collection, but the doc1 displays in italic style with gray color text and has description like this: This document does not exist, it will not appear in queries or snapshots

Is there another way which I can achieve creating path as above without getting this result?

enter image description here

Steven-Carrot
  • 2,368
  • 2
  • 12
  • 37
  • get rid of `current: "simulator"` ? – Ronnie Royston Oct 24 '22 at 00:29
  • @RonnieRoyston no no. current: "simulator" is just an object which put in the collect2. it is not a problem. even deleting that line has no problem. – Steven-Carrot Oct 24 '22 at 00:30
  • 1
    A document needs to have at least one field for it to exist. So add a field. Any field. Just make one up. See: https://stackoverflow.com/questions/47043651/this-document-does-not-exist-and-will-not-appear-in-queries-or-snapshots-but-id – Ronnie Royston Oct 24 '22 at 00:33
  • @RonnieRoyston this is the problem. I am trying to make sure while creating the path, the new document also has field, but can't figure out. – Steven-Carrot Oct 24 '22 at 00:40
  • you need to `.set.` or `.update`? See https://firebase.google.com/docs/firestore/manage-data/transactions#transactions – Ronnie Royston Oct 24 '22 at 00:53
  • are you trying to make a subCollection? – Chanpols Oct 24 '22 at 02:28
  • It'll be best if you share a complete screenshot of your Firestore. Is that random doc ID generated by `.doc()` or is it the parent document ID? Because you have `doc1` hard-coded in your code. Also please share the actual code that you are running. – Dharmaraj Oct 24 '22 at 04:50

0 Answers0