AggregateCommand.not(value: Expression): Object

View Markdown

Last edited on 2026-07-04

Supported platforms: Mini Program 2.7.4, Cloud Function 0.8.1, Web

An aggregation operator. Given an expression, if the expression returns true, not returns false; otherwise, it returns true. Note that the expression cannot be a logical expression (and, or, nor, not).

Parameters

value: Expression

Expression

Return Values

Object

API Description

The syntax is as follows:

db.command.aggregate.not(<expression>)

If the expression evaluates to false, null, 0, or undefined, it is resolved as false; otherwise, all other return values are considered true.

Example Code

Assume the collection price contains the following records:

{ "_id": 1, "min": 10, "max": 100 }
{ "_id": 2, "min": 60, "max": 80 }
{ "_id": 3, "min": 30, "max": 50 }

Retrieve records where min is not greater than 40.

const $ = db.command.aggregate
db.collection('price').aggregate()
  .project({
    fullfilled: $.not($.gt(['$min', 40]))
  })
  .end()

The result is as follows:

{ "_id": 1, "fullfilled": true }
{ "_id": 2, "fullfilled": false }
{ "_id": 3, "fullfilled": true }