5
I’m trying to recover a firebase node, but this one needs to meet two parameters, start date and end date. The knot stays the way they passed me an option would be to put one more value to date_start_end : 1478484000_1478397600, but with that you can not search between the dates. This would not be a viable option.
I also had trying to use only that firebase does not support more than one orderby
.orderByChild("date_start").startAt(mDay).endAt(mDay)
.orderByChild("date_end").startAt(mDay).endAt(mDay);
this leads to the error of
java.lang.IllegalArgumentException: You can't combine multiple orderBy calls!
Any suggestions to resolve this issue?
the date is timestamp, my intention would be to fetch the records that are between the start (date_start ) and end (date_end) dates myDay corresponds to the timestamp of the day. The query I need to mount would be to resolve the following situation: Pick one or n record that are between the start date and the end date, based on the current date. In sql would look something like this:
SELECT users.id, DATE_FORMAT(users.signup_date, '%Y-%m-%d') 
 FROM users 
 WHERE signup_date >= CURDATE() && signup_date < (CURDATE() + INTERVAL 1 DAY)
– Jefferson Rodrigues dos Santos
So in case you have a single "signup_date" field and are filtering using it. Then the logic is
signup_date > data atual && signup_date < data limite
right ? Turning to Firebase would be something like.orderByChild("signup_date").startAt(dataAtual).endAt(dataLimite);
– Lucas Queiroz Ribeiro
I understood what you put there, and the code you made makes total sense. But when I have to compare among the children as in the example of the question. Compares the date between the child node date_start and the child node date_end relative to the current day<myDay>. This would be possible?
– Jefferson Rodrigues dos Santos
In Firebase, it is not possible to search for two "Keys", I believe that if you want to do a search in the two Childs, you will have to do programmatically (Doing a query, and then filtering this query with the other data) or create an index that combines the two, the problem is that because it comes to dates I think it will not serve your purpose.
– Lucas Queiroz Ribeiro
vlw by help, will not really help me, the purpose of this would be to reduce the amount of items to be recovered from the server (firebase) side. Unfortunately I will have to search everything and filter when showing, but vlw the force.
– Jefferson Rodrigues dos Santos
@Jeffersonrodriguesdossantos, for nothing, I know that using Firebase with Javascript you can do a query in the return of the other, I do not know if on Android is possible, if you want to give one look at
– Lucas Queiroz Ribeiro
Depending on the application if it is going to run in angular 2 David East made a library for this, unfortunately there is no ara java or Swift da uma olhada la ai ta bem legal. [https://github.com/davideast/Querybase]
– Jefferson Rodrigues dos Santos