我正在努力地查询和查询实时数据库。
StreamSubscription<Event> _messagesSubscription;
DatabaseReference _messagesRef =
FirebaseDatabase.instance.reference().child('messages');
realTimeDataBaseListen() {
_messagesSubscription = _messagesRef
.childOrderBy("Group_id")
.equalTo("abc123")
.onChildChanged
.listen((Event event) {
print('Child CHANGED: ${event.snapshot.value}');
}, onError: (Object o) {
final DatabaseError error = o;
print('Error: ${error.code} ${error.message}');
});
}
但是我得到了错误:
childOrderBy() not defined
我在做什么错了?
谢谢!
答案 0 :(得分:1)
您应该使用orderByChild
:
.orderByChild("Group_id")
.equalTo("abc123")
.onChildChanged
.listen((Event event) {
检查以下内容: