Reputation: 1667
I want to display all result, where field "userGood" ending with "true". I am use next code in FirebaseListAdapter.
FirebaseListAdapter<User> firebaseSuccessfulTaskListAdapter = new FirebaseListAdapter<User>(
this, User.class,
R.layout.item_user,
FirebaseDatabase.getInstance().getReference()
.child("users").orderByChild("userGood").endAt("true")){
@Override
protected void populateView(View v, Task model, int position) { }
};
Data structure:
{
"users": {
"1": {
"name": "bob",
"userGood": "bob_true"
},
"2": {
"name": "max",
"userGood": "max_false"
},
"3": {
"name": "mike",
"userGood": "mike_true"
},
"4": {
"name": "bob",
"userGood": "bob_false"
}
}
}
When i use this code, they display to me all data with my database. Can you help me how to fix it? Thanks!
Upvotes: 0
Views: 28
Reputation: 2462
The function is endAt, not endWith. You're getting everything that comes before "true" alphabetically. The Firebase API does not support partial text matching. Either look into a third-party text search solution like ElasticSearch/Flashlight, or refactor your data model so that your queries can be made using the built-in functions. For example, why can't userGood
just be a Boolean true
or false
?
Upvotes: 3