Primer

Module Expressions

parse(expression)

Parse an expression.

This returns a JSON that contains a list of query parts, and methods for interacting with the query.

Arguments

  • expression { Expression } Any valid expression.

const expressions = require('expressions')
return expressions.parse({
    $toString: '$$NOW'
})

Returns

  • { * } The ran expression.

{
    "object": "result",
    "data": {
        "depth": 1,
        "fullPath": "$toString",
        "input": {
            "$toString": "$$NOW"
        },
        "path": "$toString",
      }}

run(expression, root)

This runs the command in the context of the current database.

Arguments

  • expression { Expression } Any valid expression.

Returns

  • { * } The ran expression.

evaluate(expression, root)

This evaluates an expression, running the expression and returning a JSON that contains a list of query parts, and methods for interacting with the query. Arguments

  • expression { Expression } Any valid expression.

Returns

  • { * } The ran expression.

Pipelines

Pipeline aggregation allows for querying, aggregating, and transforming data in multiple stages in real-time through a single API request. While query arguments allow for making simple, single-stage queries through the API, pipelines allow for more complex searches, aggregations and transformations.

pipeline.parse(expression)

This returns a JSON that contains a list of query parts, and methods for interacting with the query.

Arguments

  • expression { Expression } Any valid expression.

Returns

  • { * } The ran expression.

pipeline.run(expression, input)

This runs the command in the context of the current database.

Arguments

  • expression { Expression } Any valid expression.

Returns

  • { * } The ran expression.

Arguments

  • expression { Expression } Any valid expression.

  • input { Array|Cursor = null } An array or cursor to serve as initial input.

pipeline.evaluate(expression, input)

This evaluates an expression, running the expression and returning a JSON that contains a list of query parts, and methods for interacting with the query.

Arguments

  • expression { Expression } Any valid expression.

Returns

  • { * } The evaluated expression.

Last updated

Was this helpful?