9

I am trying to do a "$in" query with waterline I have an Array and I want to get a list of document with ids that are in the array. I don't know how to do that.

I tried:

User.find()
.where({id : {in : array}})
done(...)

But it doesn't seem to work as expected.

Any way I can do that?

Travis Webb
  • 14,688
  • 7
  • 55
  • 109
adc06
  • 793
  • 8
  • 23

1 Answers1

19

ParticleBanana answered me here: https://groups.google.com/forum/#!topic/sailsjs/dHxwsJvG5V8

I quote him here for convenience:

When an array is passed in the where criteria an IN query will automatically be run. So you can do the following:

User.find().where({ id: [1,2,3] }).exec(function(err, users) { ... })`

It worked perfectly.

leviathanbadger
  • 1,682
  • 15
  • 23
adc06
  • 793
  • 8
  • 23