0

Is there a way to populate students ?

"cohortStudents": {
  "cohort-id-4": {
    "cohortId": "cohort-id-4",
    "instructorId": "CZVLBcZ7lQe2OUcHdDLjW4OVFaB2",
    "students": {
      "student-id-1": true,
      "student-id-2": true,
      "student-id-3": true
    }
  }
}

So basically i can get data from cohortStudents by
https://[projectname].firebaseio.com/cohortStudents.json?orderBy="cohortId"&equalTo="cohort-id-4"

And i will get object but students: {} will have still student-id-1 etc

Is there a way to get data look like students: { student-id-1: { name: '', email: '' } }

Hope your help

Андрей Гузюк
  • 2,134
  • 6
  • 29
  • 53

1 Answers1

1

Firebase Database queries read child nodes from a single location only. There is no support for server-side joins.

To get the users that are referenced from students you will have to do a client-side join: loading each user individually.

I highly recommend using a Firebase SDK to do this, since it is optimized for this type of use-case. See my answer to this question for more.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807