Google Firebase seems to be difficult to wrap my head around... I have no problems in getting documents and their data out of a collection, but when I try to simply get a list of all the IDs inside a collection, I am not able to figure out what the call should look like. I have tried searching for the info, but without success.
I have a function declared in my service component, which looks like this:
getCollRegistrationNumbers(): firebase.firestore.CollectionReference {
return firebase.firestore().collection(`storedItems`);
}
Then in e.g. the Search page of my app, I am calling the function from my component, but whatever I try, it returns empty.
Given the service function above, how should I complete the code below to just git a list of the IDs?
this.fireStore.getCollRegistrationNumbers().get()
.then(snapshot => {....})
If you need a count, just use the collection path and prefix it with counters . As this approach uses a single database and document, it is limited to the Firestore constraint of 1 Update per Second for each counter.
You can view all your Cloud Firestore data in the Firebase console. From the Cloud Firestore Data tab, click on a document or collection to open the data nested within that item.
Look at how your documents are displayed in an italic font: this means, in the console, that these documents are only present as "container" of one or more sub-collection but that they are not "genuine" documents.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With