Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getQueryResultFromArray (allDocs, expression) {
expression = this.normalizeExpression(expression)
if (expression.$aggregate) {
let agg = new Mingo.Aggregator(expression.$aggregate)
return agg.run(allDocs)
}
let mingoQuery = new Mingo.Query(expression.$query)
let cursor = mingoQuery.find(allDocs)
if (expression.$orderby) cursor.sort(expression.$orderby)
if (expression.$skip) cursor.skip(expression.$skip)
if (expression.$limit) cursor.limit(expression.$limit)
if (expression.$findOptions) {
for (let key in expression.$findOptions) {
let value = expression.$findOptions[key]
cursor = cursor[key](value)