Reputation: 180
I'm working on a project which needs to select data from Firebase on multiple fields.
I have a firebase database like this:
[{
date: "2016-01-29"
done: false
task: "hello world"
},
{
date: "2016-01-29"
done: false
task: "hello world"
}]
Now I want to query all data with date is today and done is true.
I look around google for a while but there's nothing work. Is there any one can please help me to figure this out?
Upvotes: 1
Views: 3210
Reputation: 598901
You can only query on a single property with Firebase queries. So either you'll have to do the rest of the filtering client-side or you'll have to combine the values into a single 'date_done' property.
[{
date: "2016-01-29",
done: false,
date_done: "2016-01-29_false",
task: "hello world1"
},
{
date: "2016-01-29",
done: false,
date_done: "2016-01-29_false",
task: "hello world"
}]
Now you can get all the queries that were done on January 29 with:
ref.orderByChild('date_done').equalTo('2016-01-29_true').on(...
For some more information from people who asked similar questions, see:
Upvotes: 1