Skip to content

Get all the documents from a collection firebase angular/typescript [closed]

Hello everybody I am check in the official webside of firebase how to retrieve all the documents from a collection but it gives me just 1 and it is not the first one not the last but somewhere in the middle and it is always the same object and I couldnt understand why it is so. Can you check and maybe see what I am doing wrong? I am always getting the document: “companion_live”

 private firestore: AngularFirestore;
  constructor(private routingService: RoutingService, firestore: AngularFirestore) {
    this.firestore = firestore;
async ngAfterViewInit() {
        const citiesRef = this.firestore.firestore.collection('user');
        const snapshot = await citiesRef.get();
        snapshot.forEach((doc) => {
        if (this.allTruckRoute.length > 0) {
          this.allTruckRoute.forEach(route => this.trucks.push({id: route, selected: false} as SelectedTrucks));

this is how my schema looks like:

enter image description here


You are only getting one document because there is only one actual document in the users collection. The documents you see in italics are not actual documents at all. They are merely placeholders for missing documents that have subcollections. If you click into that “missing” document, you will see that it has no fields, but you are able to navigate further into its nested subcollections. These missing documents will disappear from the console when their subcollections are all removed.

The only document present is “companion_live”, so that’s the only one you will get from a query on users.

See also: