1.0.15 • Published 4 years ago

@aiflow/mast v1.0.15

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

MAST (Mongo Abstract syntax tree)

A simple work in progress Abstract syntax tree (AST) builder that can be converted to JSON, Mongo Query and Mongo Query Expression.

Example

Here is some simple examples.

Create AST and return as a Mongo Query.

import { CompoundCondition, FieldCondition } from "@aiflow/mast"

const ast = new CompoundCondition("and", [
  new FieldCondition("eq", "name", "Vemund Eldegard)
])

return ast.toQuery()

Will return:

{
  "$and": [
    {
      "name": { 
        "$eq": "Vemund Eldegard
      }
    }
  ]
}

Return as Mongo Query Expression ($expr)

import { CompoundCondition, FieldCondition } from "@aiflow/mast"

const ast = new CompoundCondition("and", [
  new FieldCondition("eq", "name", "Vemund Eldegard)
])

return ast.toQueryExpression()

Will return:

{
  "$expr": {
    $and: [
      {
        "$eq": ["$name", "Vemund Eldegard"]
      }
    ]
  }
}
1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago