Query.prototype.elemMatch()

Parameters
  • path «String|Object|Function»
  • filter «Object|Function»
Returns:
  • «Query» this

Specifies an $elemMatch condition

Example

  1. query.elemMatch('comment', { author: 'autobot', votes: {$gte: 5}})
  2. query.where('comment').elemMatch({ author: 'autobot', votes: {$gte: 5}})
  3. query.elemMatch('comment', function (elem) {
  4. elem.where('author').equals('autobot');
  5. elem.where('votes').gte(5);
  6. })
  7. query.where('comment').elemMatch(function (elem) {
  8. elem.where({ author: 'autobot' });
  9. elem.where('votes').gte(5);
  10. })