你好我们正在尝试选择包含特定名字学生的课程,这可能是因为在课程上注册了多个学生,但我仍然无法解决这个问题。 (非常相似的查询,即课程名称完全正常)数据快照看起来像{key:course,value:null},即使有应该满足标准的课程Firebase structure
Query query= mDatabase.child("courses").orderByChild("students/name").equalTo("Dominik Skoczylas");
query.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()) {
for (DataSnapshot child : dataSnapshot.getChildren())
{
userCourse = child.getValue(Course.class);
}
}}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
"courses" : {
"-Kfo-G37vwtUkWAv1zE_" : {
"modules" : [ {
"lectures" : [ {
"endTime" : {
"date" : 1,
"day" : 4,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1517446861000,
"timezoneOffset" : 0,
"year" : 118
},
"room" : {
"name" : "J100"
},
"starTime" : {
"date" : 1,
"day" : 3,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1485910861000,
"timezoneOffset" : 0,
"year" : 117
},
"topic" : "Distributed 1"
}, {
"endTime" : {
"date" : 1,
"day" : 4,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1517446861000,
"timezoneOffset" : 0,
"year" : 118
},
"room" : {
"name" : "J200"
},
"starTime" : {
"date" : 1,
"day" : 3,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1485910861000,
"timezoneOffset" : 0,
"year" : 117
},
"topic" : "Distributed 2"
} ],
"name" : "Distributed computing"
}, {
"lectures" : [ {
"endTime" : {
"date" : 1,
"day" : 4,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1517446861000,
"timezoneOffset" : 0,
"year" : 118
},
"room" : {
"name" : "J100"
},
"starTime" : {
"date" : 1,
"day" : 3,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1485910861000,
"timezoneOffset" : 0,
"year" : 117
},
"topic" : "Advanced 1"
}, {
"endTime" : {
"date" : 1,
"day" : 4,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1517446861000,
"timezoneOffset" : 0,
"year" : 118
},
"room" : {
"name" : "J200"
},
"starTime" : {
"date" : 1,
"day" : 3,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1485910861000,
"timezoneOffset" : 0,
"year" : 117
},
"topic" : "Advanced 2"
} ],
"name" : "Advanced internet"
}, {
"lectures" : [ {
"endTime" : {
"date" : 1,
"day" : 4,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1517446861000,
"timezoneOffset" : 0,
"year" : 118
},
"room" : {
"name" : "J100"
},
"starTime" : {
"date" : 1,
"day" : 3,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1485910861000,
"timezoneOffset" : 0,
"year" : 117
},
"topic" : "Concurrent 1"
}, {
"endTime" : {
"date" : 1,
"day" : 4,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1517446861000,
"timezoneOffset" : 0,
"year" : 118
},
"room" : {
"name" : "J200"
},
"starTime" : {
"date" : 1,
"day" : 3,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1485910861000,
"timezoneOffset" : 0,
"year" : 117
},
"topic" : "Concurrent 2"
} ],
"name" : "Concurrent programming"
} ],
"name" : "Software Engineering",
"students" : [ {
"name" : "Dominik Skoczylas"
}, {
"name" : "Marta Mleczko"
}, {
"name" : "Zenon Zenon"
}, {
"name" : "Matt Damon"
} ]
},
"-Kfo-G3G4ndKYpKHhtgV" : {
"modules" : [ {
"lectures" : [ {
"endTime" : {
"date" : 1,
"day" : 4,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1517446861000,
"timezoneOffset" : 0,
"year" : 118
},
"room" : {
"name" : "J100"
},
"starTime" : {
"date" : 1,
"day" : 3,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1485910861000,
"timezoneOffset" : 0,
"year" : 117
},
"topic" : "Concurrent 1"
}, {
"endTime" : {
"date" : 1,
"day" : 4,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1517446861000,
"timezoneOffset" : 0,
"year" : 118
},
"room" : {
"name" : "J200"
},
"starTime" : {
"date" : 1,
"day" : 3,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1485910861000,
"timezoneOffset" : 0,
"year" : 117
},
"topic" : "Concurrent 2"
} ],
"name" : "Concurrent programming"
}, {
"lectures" : [ {
"endTime" : {
"date" : 1,
"day" : 4,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1517446861000,
"timezoneOffset" : 0,
"year" : 118
},
"room" : {
"name" : "J100"
},
"starTime" : {
"date" : 1,
"day" : 3,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1485910861000,
"timezoneOffset" : 0,
"year" : 117
},
"topic" : "Graphics 1"
}, {
"endTime" : {
"date" : 1,
"day" : 4,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1517446861000,
"timezoneOffset" : 0,
"year" : 118
},
"room" : {
"name" : "J200"
},
"starTime" : {
"date" : 1,
"day" : 3,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1485910861000,
"timezoneOffset" : 0,
"year" : 117
},
"topic" : "Graphics 2"
} ],
"name" : "Graphics"
}, {
"lectures" : [ {
"endTime" : {
"date" : 1,
"day" : 4,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1517446861000,
"timezoneOffset" : 0,
"year" : 118
},
"room" : {
"name" : "J100"
},
"starTime" : {
"date" : 1,
"day" : 3,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1485910861000,
"timezoneOffset" : 0,
"year" : 117
},
"topic" : "Artificial 1"
}, {
"endTime" : {
"date" : 1,
"day" : 4,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1517446861000,
"timezoneOffset" : 0,
"year" : 118
},
"room" : {
"name" : "J200"
},
"starTime" : {
"date" : 1,
"day" : 3,
"hours" : 1,
"minutes" : 1,
"month" : 1,
"seconds" : 1,
"time" : 1485910861000,
"timezoneOffset" : 0,
"year" : 117
},
"topic" : "Artificial 2"
} ],
"name" : "Artificial intelligence"
} ],
"name" : "Computer Science",
"students" : [ {
"name" : "Leonardo Dicaprio"
}, {
"name" : "John Lennon"
}, {
"name" : "Anthony Bond"
}, {
"name" : "Andy Jones"
} ]
}
}