node.js - Mongoose use array in find().where() -
i have array of strings want use parameter finding documents in mongodb.
basically want is
// using query builder person.   find().   where('name.last').equals('ghost' || 'etc' || 'etc').... but instead of using bunch of or statements, want pass array of strings.
is possible?
just use .in method, taking $in operator in play:
person.   find().   where('name.last').in(['ghost', 'foo', 'bar']) quoting the mongodb docs:
the
$inoperator selects documents value of field equals value in specified array.
Comments
Post a Comment