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

Queries: "between" or "range" queries (<, >) #6358

Closed
mikermcneil opened this issue Sep 8, 2013 · 6 comments
Closed

Queries: "between" or "range" queries (<, >) #6358

mikermcneil opened this issue Sep 8, 2013 · 6 comments

Comments

@mikermcneil
Copy link
Member

Presently, you can do > and <, but you can't do between.

Example usage:

// Get all users between the ages of 18 and 21
User.findAll({
  age: {
    '>=': 18,
    '<': 21
  }
}).done(function (err, users) {
  if (err) return res.send(err,500);
  res.json(users);
});

( PS- this isn't high priority really, just cleaning up-- migrated from: #274 )

@terox
Copy link

terox commented Nov 29, 2013

+1

@artworkad
Copy link
Contributor

👍 WOW guys this is essential

@artworkad
Copy link
Contributor

However using native() we can achieve the same http://cookbook.mongodb.org/patterns/date_range/

@terox
Copy link

terox commented Jan 7, 2014

@artworkad, I think that using native method is a patch, but not a solution :)

I think also that this feature is essential

@v-sullivan
Copy link

Hi all,
Sorry to say that during my fist post but yes, I think that it's an important point too !
Getting a set between 2 dates must be straighforward and not depending on the underneath datastore technology.
Saying that, I know that it's not trivial and despite that I am a Sails framework enthusiast I don't really know how to help.

@particlebanana
Copy link
Contributor

You can do:

User.find({
    date: { '>': new Date('2/4/2014'), '<': new Date('2/7/2014') }
}).exec(/* ... */);

@johnabrams7 johnabrams7 transferred this issue from balderdashy/waterline May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants