lib/memory-engine.js
function findByQuery(query, options, callback) {

    if (typeof options === 'function') {
      callback = options
      options = {}
    }

    var cursor = Mingo.find(data, query, options && options.fields)
    if (options && options.sort) cursor = cursor.sort(options.sort)
    if (options && options.limit) cursor = cursor.limit(options.limit)

    var allData = getObjectCopies(cursor.all())

    if (callback === undefined) {

      return es.readArray(allData).pipe(es.map(function (data, cb) {
          self.emit('received', data)
          cb(null, data)
        }))
    } else {
      callback(null, allData)
    }

  }
function findByQuery(query, options, callback) {

    if (typeof options === 'function') {
      callback = options
      options = {}
    }

    var cursor = Mingo.find(data, query, options && options.fields)
    if (options && options.sort) cursor = cursor.sort(options.sort)
    if (options && options.limit) cursor = cursor.limit(options.limit)

    var allData = getObjectCopies(cursor.all())

    if (callback === undefined) {

      return es.readArray(allData).pipe(es.map(function (data, cb) {
          self.emit('received', data)
          cb(null, data)
        }))
    } else {
      callback(null, allData)
    }

  }
function findByQuery ( query , options , callback ) { if ( typeof options === 'function' ) { callback = options options = { } } var cursor = Mingo . find ( data , query , options && options . fields ) if ( options && options . sort ) cursor = cursor . sort ( options . sort ) if ( options && options . limit ) cursor = cursor . limit ( options . limit ) var allData = getObjectCopies ( cursor . all ( ) ) if ( callback === undefined ) { return es . readArray ( allData ) . pipe ( es . map ( function ( data , cb ) { self . emit ( 'received' , data ) cb ( null , data ) } ) ) } else { callback ( null , allData ) } }
Performs a find on the data by search query.

Sorting can be done similarly to mongo by providing a $sort option to
the options object.

The query can target fields in a subdocument similarly to mongo by passing
a string reference to the subdocument in dot notation.

@param {Object} query to search by
@param {Object} search options
@param {Function} callback
@api private
Performs a find on the data by search query .