14

I cannot figure out how to create a new Collection with the node.js firestore api. Any suggestions?

1 Answer 1

42

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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
note that deleting a doc doesn't delete its subcollection! u need to delete subcollection separately.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.