Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ordering a query does not work when using an 'IN' operator #19

Open
uncvrd opened this issue Feb 16, 2019 · 3 comments
Open

Ordering a query does not work when using an 'IN' operator #19

uncvrd opened this issue Feb 16, 2019 · 3 comments

Comments

@uncvrd
Copy link

uncvrd commented Feb 16, 2019

Hi there, I'm hoping to use your library while I wait for firebase to add an "IN" query for "WHERE" in Firestore! I'm trying to use a combination of "IN" operator and orderBy date. However, the results display in the order that they are queried from the artistUIDs array.

So for example if my array of artistUIDs equals [1,4,9] then the results are displayed with 1 being the first item and 9 being the last regardless of what the .orderBy order is set to

  inOperator(artistUIDs: string[], date) {
    var submissions$ = linq(firebase.firestore()).from('submissions');
    return submissions$
    .limit(15)
    .orderBy({ submissionReleaseDate: "desc" })
    .where({
      // in operator
      submissionArtistUID: artistUIDs,
      submissionApproved: true
    })
  }

As you can see by the image below:

image

What am I doing wrong?

The dates in each firestore object are saved as unix timestamp strings such as:

submission: {
    submissionReleaseDate: '1550707200'
}

What am I doing wrong?

Thanks!

@uncvrd uncvrd changed the title Query loses sort order when using a specific "where" method Ordering a query does not work when using an 'IN' operator Feb 16, 2019
@uncvrd
Copy link
Author

uncvrd commented Feb 16, 2019

I've also discovered that the limit(15) does not limit the results to 15 either while using an "IN" operator! If I remove the artistUIDs array from the WHERE query and just query for all of the submissions, the limit method works

@linq2js
Copy link
Owner

linq2js commented Feb 16, 2019

Let me test this case, thank for your feedback

@uncvrd
Copy link
Author

uncvrd commented Feb 16, 2019

@linq2js you're welcome, let me know if you need more information! The orderby works as expected when I remove my array artistUIDs from the query, so it appears that is what is messing the order up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants