1

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?

1 Answer 1

1

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:

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Frank a lot. I figure out what need to do with the issues. I have to redesign my database and add some fields for further purpose.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.