Create doc with subcollection in one shot

后端 未结 1 1427
小蘑菇
小蘑菇 2020-12-12 02:13

Let\'s say I have collection called root

Can I create document with its subcollection in one call?

I mean if I do:

db.Collection(\"root\")         


        
相关标签:
1条回答
  • 2020-12-12 03:02

    The code you shared doesn't create an actual document. It merely "reserves" the ID for a document in root and then creates a sub collection under it with an actual doc11 document.

    Seeing a document name in italics in the Firestore console indicates that there is no physical document at a location, but that there is data under the location. This is most typical when you've deleted a document that previously existed, but your code is another way accomplishing the same.

    There is no way to create two documents in one call, although you can create multiple documents in a single transaction or batch write if you want.

    0 讨论(0)
提交回复
热议问题