Query.prototype.where()

Parameters
  • [path] «String|Object»
  • [val] «any»
Returns:
  • «Query» this

Specifies a path for use with chaining.

Example

  1. // instead of writing:
  2. User.find({age: {$gte: 21, $lte: 65}}, callback);
  3. // we can instead write:
  4. User.where('age').gte(21).lte(65);
  5. // passing query conditions is permitted
  6. User.find().where({ name: 'vonderful' })
  7. // chaining
  8. User
  9. .where('age').gte(21).lte(65)
  10. .where('name', /^vonderful/i)
  11. .where('friends').slice(10)
  12. .exec(callback)