I cannot figure out how to create a new Collection with the node.js firestore api. Any suggestions?
1 Answer
Collections are automatically created when you add/write a document to them. There is no need (nor API) to explicitly create a collection.
From the documentation:
Collections and documents are created implicitly in Cloud Firestore. Simply assign data to a document within a collection. If either the collection or document does not exist, Cloud Firestore creates it.
2 Comments
hybrid9
Is it possible to create a document with fields and a subcollection at the time of a root collection creation? I'm finding I need to create my document first, then create my subcollection in two steps
GorvGoyl
note that deleting a doc doesn't delete its subcollection! u need to delete subcollection separately.