How to use the mingo.Aggregator function in mingo

To help you get started, we’ve selected a few mingo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github amelisa / amelisa / src / mongo / MongoQueries.js View on Github external
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)

mingo

MongoDB query language for in-memory objects

MIT
Latest version published 15 days ago

Package Health Score

83 / 100
Full package analysis