Back to Lowdefy

@lowdefy/operators-mql

code-docs/plugins/operators/mql.md

5.2.02.2 KB
Original Source

@lowdefy/operators-mql

MongoDB Query Language operators for Lowdefy. Filter and query data using MongoDB-style syntax.

Overview

MQL operators let you use MongoDB query syntax to filter arrays and objects in your configuration.

Key Operators

OperatorPurpose
_mql_testTest if object matches query
_mql_exprEvaluate aggregation expression
_mql_aggregateRun aggregation pipeline on array

_mql_test

Test if an object matches a query:

yaml
isActive:
  _mql_test:
    on:
      _state: user
    test:
      status: active
      age:
        $gte: 18

_mql_expr

Evaluate aggregation expression:

yaml
total:
  _mql_expr:
    expr:
      $multiply:
        - $quantity
        - $price
    on:
      _state: item

_mql_aggregate

Run aggregation pipeline:

yaml
summary:
  _mql_aggregate:
    on:
      _request: getOrders
    pipeline:
      - $match:
          status: completed
      - $group:
          _id: $category
          total:
            $sum: $amount
          count:
            $sum: 1

MongoDB Query Operators

Supported query operators:

OperatorPurpose
$eqEqual
$neNot equal
$gtGreater than
$gteGreater or equal
$ltLess than
$lteLess or equal
$inIn array
$ninNot in array
$andLogical AND
$orLogical OR
$notLogical NOT
$regexRegular expression
$existsField exists

Filter Array Example

yaml
activeUsers:
  _mql_aggregate:
    on:
      _request: getUsers
    pipeline:
      - $match:
          active: true
          role:
            $in:
              - admin
              - editor

Use Cases

  • Client-side data filtering
  • Complex conditional logic
  • Data transformation without requests
  • Aggregating request responses