Firebase Firestore list of all IDs in a collection

Viewed 8142

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 => {....})
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.

Related