I have firebase database with structure
Now I want to select only names with given gender and qualities. I wrote code like this
private NameImpl.Gender mGender;
private String[] mQualities;
...
public void GetNames()
{
mRef.orderByChild("Gender").equalTo(mGender.name()).addValueEventListener(new ValueEventListener()
{
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
getData(dataSnapshot);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
But I can't understand how to add here requirement that Qualities string in database must contain all words from mQualities.
You can't do this with Firebase Realtime Database without some significant changes to your schema. Realtime Database doesn't have the capability to perform filtering on multiple conditions (some people say "multiple where clauses" in SQL terms). If you want to check for matches on multiple things, you'll have to create a composite field that contains a combination of the things you're looking for. For example, you'll need a string value that has gender and all the qualities concatenated together in predictable fashion, then have clients search for that string.
Firestore allows you to filter on multiple conditions, but you still can't search for sets of objects. You'll still need a special field that concatenates all the qualities together.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.