Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Firestore list of all IDs in a collection

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.

enter image description here

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 => {....})
like image 273
El Fred Avatar asked Nov 05 '18 17:11

El Fred


People also ask

How do you get a collection count in firestore?

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.

How do I check my Firebase collection?

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.


1 Answers

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.

like image 116
Renaud Tarnec Avatar answered Oct 21 '22 06:10

Renaud Tarnec