We are migrating an app from Parse to Firebase and I'd like to build a UI where I can show the student name along with the classroom that s/he belongs to from the following Firebase data structure. For example, the class room name for aluck
is 10th Grade
.
{
"students": {
"aluck": {
"firstName": "Andrew",
"lastName": "Luck",
"classroom": "-KJlJhyNH6ImKke-qAd-"
},
"bmorino": {
"firstName": "Beth",
"lastName": "Morino",
"classroom": "-KJlJhyNH6ImKke-qAd-"
}
},
"classRooms": {
"-KJlJhyNH6ImKke-qAd-": {
"location": "Down stairs",
"name": "10th Grade",
"students": {
"aluck": true,
"bmorino": true,
}
}
}
}
My assumption was when I do something like this using the Firebase JavaScript SDK,
var db = firebase.database();
db.ref("students/aluck").on("value", function(snap) {
// success method will expose the classroom object with it
});
it will expose the classRooms
object, but it does not.
In Parse, I was able to do
var query = new Parse.Query(Student);
query.include("ClassRoom");
and it'll expose both the Student
and ClassRoom
objects.
Any help is appreciated.