Repository navigation
V3: orderByChild + startAt or endAt #174
Description
Activity
Hmm weird one @florianbepunkt - database in the current pushed up state of my branch has not been touched bar a PR from @BlooJeans which was on master that I manually pulled in.
Will look at this today and get back to you, the example helps, cheers!
@florianbepunkt looks like @chrisbianca fixed this issue 3 days ago on my branch - have you tried pulling the latest?
This commit:
Salakar@ec9f488@Salakar I did. To make sure I just installed it again via
npm install --save https://github.com/Salakar/react-native-firestack.gitThe commit only changes things on android side… I see this problem with iOS.
I only updated the Android side as that's where I'd noticed the issue.
Just taken a look and a similar sort of change does need to happen on the iOS side - I'll see if I can take a look in a little while...@florianbepunkt oh ok my bad, thought you were having an android issue sorry.
@chrisbianca that would be awesome thanks!
I'm not sure if this is related… using a fresh install from Salakar's fork I see the same issue on android.
Using my sample data
firestack .database() .ref('messages/-KXlqrDgbJg_-FJCoDfE/') .orderByChild('createdAt') .startAt(1480609558242) .once('value') .then((snapshot) => { console.log('my snap', snapshot); })returns zero values…
Ok, I don't have any data setup to test this with at the moment.
When I get some time later on, I'll take a look and see if I can figure out what's going on.@chrisbianca okay. I throw together a simple test project and upload it if that helps
@florianbepunkt that would be great!
@chrisbianca @Salakar Okay, here we go… https://github.com/florianbepunkt/fireStackQuery
you can clone the repo, run npm install and run it. I've tested it on ios and it reproduces the issue.
So I've figured out why it's broken in Java... It's passing the startAt and endAt as a String rather than a number. The fix is an awful lot of repetitive code but I can't think of a better way to work around it! Just pushed the fix to the v3 branch and sorted for boolean types too.
Will try and look at iOS now...
Reacted by dang819@chrisbianca great! just checked android version with your commit
I've just committed the equivalent fix for iOS. I rewrote a large part of the iOS database module to bring it more in line with Android and stop regenerating firebase references unnecessarily. Let me know if you have any other issues...
10 remaining items
@BlooJeans Thanks for the clarification. Makes sense.
@florianbepunkt @chrisbianca - @Ehesp and I are having the same issue at the moment:
firestack .database() .ref('matches') .orderByChild('startsAt') .startAt(1480982400) .endAt(1481068799) .on('value', snap => console.log(snap.val()));
Returns no results on firestack. The exact same query however on the web sdk returns correctly and gives
matchesall for that time range.We're using the head of my fork which includes your changes @chrisbianca - am i missing something?
A possibly better way to handle the value types would be get the types on the JS side i.e. it gets sent over as
startsAt:number:1234567890then we don't need to do any guess work on either ios / android - thoughts?Sorry for the slow responses also, have been ill, urgh.
Reacted by Andrew Henderson@Salakar I can confirm (sorry @chrisbianca didn't notice since I had no need to combine startAt and endAt yet)
although I get results, when I combine startAt and endAt
both queries below return the same results. updated my test project https://github.com/florianbepunkt/fireStackQuery
firestack .database() .ref('messages/-KXlqrDgbJg_-FJCoDfE/') .orderByChild('createdAt') .endAt(1480609558242) .once('value') .then((snapshot) => { console.log('queryTest orderByChild endAt test > snapshot', snapshot); }) firestack .database() .ref('messages/-KXlqrDgbJg_-FJCoDfE/') .orderByChild('createdAt') .startAt(1480609558242) .endAt(1480617793311) .once('value') .then((snapshot) => { console.log('queryTest orderByChild startAt and endAt test > snapshot', snapshot); })@florianbepunkt thanks, we've been discussing off this thread and I'm just working on a fix
@chrisbianca alright. just fyi: I tested above only on ios. if I can help in any way let me know.
@florianbepunkt I've just pushed a fix which I've tested on iOS. Would be great if you're able to confirm that it's working for you now too
@chrisbianca works on ios. tested orderByChild with startAt, endAt and both combined.
Excellent! @Salakar when you're happy, I think this can be closed again
Also works on my end. Nice one 👍 (Android)
Closing issue as it's now resolved completely 👍
There is something bizarre happening here, this same error is happening only in the iPhone 5, both in the simulator and on a real device as well, I am on Salakar's branch, has anyone ever tested on an iPhone 5 before and got this error?
I am still not getting the expected results.
firestack.database .ref('events') .orderByChild('timestamp') .endAt(1490331248253) .once('value') .then((snapshot) => { console.log('queryTest orderByChild endAt test > snapshot', snapshot); })
This returns all results rather than stopping at the timestamp provided.
The following provides no results at all despite having records in the database that have those exact timestamps:
firestack .database .ref('events') .orderByChild('timestamp') .startAt(1490331248253 ) .endAt(1490331422094) .once('value') .then((snapshot) => { console.log('queryTest orderByChild startAt and endAt test > snapshot', snapshot); })
@chrisbianca What push are you referring to? Can you link to the commit?
ping: @Salakar
@AndrewHenderson the above mentioned fixes happened on the v3 version of firestack, your code above looks like you're currently using the old firestack version.
e.g.
databasebecamedatabase()on the new version to match the web sdk.v3 was my fork: https://github.com/Salakar/react-native-firestack
@Salakar Sorry to bother you again. It seems like orderByChild is not working, at least when used with startAt or endAt. I have a list of message objects that I want to query based on their timestamp.
This code returns zero results
while this code returns all results
Based on my sample data below…both results are wrong. The first example should return the first last two objects, the second example should return the first two objects.
I tried both the v3 branch of this repo as well as master branch of your fork. Based on the sample data the query above should return the first object. But nothing is returned