javascriptnode.jsfirebasegoogle-cloud-firestore

What's the system that I can create a new collection of a document in Firebase Firestore?


I explored the docs but couldn't figure out that how can I create a new collection of, suppose this default user which is located in users collection. Now I created a collection for this document manually named notes. But how can I code it in JavaScript? I just got to create new document in their documentations. A little help would be appreciated.

enter image description here

I tried to explore their documentations for creating new collection of a document.


Solution

  • You don't have to do anything special at all to create a new collection or subcollection. All you have to do is write the code to create the document in the collection you want, and the collection will be created automatically for you if it doesn't already exist. When you delete the last document from a collection, the collection will be gone.

    Pro tip: Firestore collections don't even really "exist" at all in the same way as a normal computer filesystem folder, so it's not helpful to think of them like that. All they do is group documents for the purpose of performing queries - they have no attributes, properties, or permissions properties of their own.