问题描述
我想检索我的firebase数据库中所有类型为Gospel的数据。 p
这是我的数据库:
pre $ DatabaseReference infoRef = FirebaseDatabase.getInstance()。geReference ).child( 信息); orderByValue()。equalTo(Gospel)。addValueEventListener(new ValueEventListener(){
@Override
public void onDataChange(DataSnapshot())
infoRef.orderByChild(genre dataSnapshot){
log.i(data,dataSnapshot.toString());
}
$ b $ @Override
public void onCancelled(DatabaseError databaseError){
}
});
我需要其他查询,因为多个orderBy是无效的。
感谢...
Firebase中不允许多个orderBy
$ p
$ b $ pre $ infoRef.orderByChild(genre)。equalTo(Gospel)。addValueEventListener(new ValueEventListener(){
@Override
public void onDataChange(DataSnapshot dataSnapshot){
log.i(data,dataSnapshot.toString());
}
@Override
public void onCancelled(DatabaseError databaseError){
$ b}
});
I want to retrive all data in my firebase database which genre has "Gospel"
Here's my database:
DatabaseReference infoRef = FirebaseDatabase.getInstance().geReference().child("info");
infoRef.orderByChild("genre").orderByValue().equalTo("Gospel").addValueEventListener( new ValueEventListener(){
@Override
public void onDataChange(DataSnapshot dataSnapshot){
log.i("data", dataSnapshot.toString());
}
@Override
public void onCancelled(DatabaseError databaseError){
}
});
I need other query because multiple orderBy is invalid.
Thanks...
Multiple orderBy are not allowed in Firebase
Try this
infoRef.orderByChild("genre").equalTo("Gospel").addValueEventListener( new ValueEventListener(){
@Override
public void onDataChange(DataSnapshot dataSnapshot){
log.i("data", dataSnapshot.toString());
}
@Override
public void onCancelled(DatabaseError databaseError){
}
});
这篇关于Android firebase查询与多个orderBy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!