mase

findOne

This method is just sugar on top of find enforcing it to always return an object or null if nothing was found.

var foundOne = find(fields, {
  $test: [Function] // if given
  $break: true,
  $count: false
})[0];

spec

function findOne(fields[, options|function $test])

Same as find's spec, differences below

options properties

  • $count is always set to false
  • $break is always set to true

returns

  • the object document if found
  • null otherwise