Passing list of keys as argument and fetching data from another class

Hi All,

I have a class in firebase which has list of keys present as reference. Corresponding to these IDs, there is another class which contains details of these objects. Here is the example:

"groupdetails" : {
"DCuf5MvTlpQa0LC4BoJWjfkIiFfc2": {
"DCuf5MvTlpQa0LC4BoJWedIiFfc2" : true,
"G54AUWnhHHQ2C3Fb9MHsbCTSm7r1" : true,
"Kxtizt7vc0cmjWATtI4N3h6iHlE3" : true 
}
}
 "userdetails" : {
    "DCuf5MvTlpQa0LC4BoJWedIiFfc2" : {
      "datecreated" : 1494347464285,
      "firstname" : "something@gmail.com",
      "lastname" : "name",
      "gender" : "male"
    },
    "G54AUWnhHHQ2C3Fb9MHsbCTSm7r1" : {
      "datecreated" : 1494347464285,
      "firstname" : "something@gmail.com",
      "lastname" : "name",
      "gender" : "male"
    },
    "Kxtizt7vc0cmjWATtI4N3h6iHlE3" : {
      "datecreated" : 1494347464285,
      "firstname" : "something@gmail.com",
      "lastname" : "name",
      "gender" : "male"
    },
    "ST9mjjTIGwh9J6TBVTFkLVL4vu32" : {
     "datecreated" : 1494347464285,
      "firstname" : "something@gmail.com",
      "lastname" : "name",
      "gender" : "male"
    },
    "s7fyHY8nKuaQ09bvipKlDq9POpw2" : {
     "datecreated" : 1494347464285,
      "firstname" : "something@gmail.com",
      "lastname" : "name",
      "gender" : "male"
    },
    "yTvhqXDVPgf7bJ1BN9RTBxaJtt72" : {
      "datecreated" : 1494347464285,
      "firstname" : "something@gmail.com",
      "lastname" : "name",
      "gender" : "male"
    }
  }

I want to fetch all the IDs of the user present in one particular group from “groupdetails” class and want to show details of all these users on my page after picking it from “userdetails” class. Please suggest the right method to fetch and display these details.

Ok. So i think i have moved onto next step. I am fetching userdetails using below function:

this.af.database.list('/groupdetails/'+DCuf5MvTlpQa0LC4BoJWjfkIiFfc2, { preserveSnapshot: true})
//This returns all the userdetails id in one group.
    .subscribe(snapshots=>{
        snapshots.forEach(snapshot => {
          console.log(snapshot.key, snapshot.val());
          //Printing all the userdetails id.
          this.userData.getUserDetails(snapshot.key).subscribe(data=>{
            console.log(data);
          });
        });
    })
   getUserDetails(userdetailsid : string): any {
    return this.af.database.object('/userdetails/' + userdetailsid );
  }

Using this i am able to fetch required data but i want to add this in an array so that i can publish all the userdetails on my HTML page. I think i will have to add promise.all() somewhere but not sure how do we do that.

I’m not seeing a function, so I can’t tell what is intending to be returned, but I think you want to look at rxjs’s mergeMap and forkJoin operators.

I basically want to return all the objects from the userdetails class on the basis of the keys fetched from groupdetails class and want to display them on my page using *ngFor.