Okay, so there is this "Reference" thing that I don't get about Firebase:
const docRef = firestore.collection('users').doc();
You can you get a "reference" of a Document but you can't get a reference of a Collection?
Why?
Clearly there can be multiple docs in a collection but there can also be multiple collections in a doc, right? So how is that different?
CodePudding user response:
In Firebase SDKs you will find DocumentReference
s and CollectionReference
s.
A
DocumentReference
refers to a document location in a Firestore database and can be used to write, read, or listen to the location. The document at the referenced location may or may not exist.
A
CollectionReference
object can be used for adding documents, getting document references, and querying for documents.
Note that a CollectionReference
can refer to root collections as well as to sub-collections under a Document.