AggregateCommand.neq(value: Expression[]): Object

支持端:小程序 2.7.4 起, 云函数 0.8.1

聚合操作符。匹配两个值,如果不相等则返回 true,否则返回 false

参数

value: Expression[]

[<value1>, <value2>]

返回值

Object

API 说明

语法如下:

  1. db.command.aggregate.neq([<value1>, <value2>])

示例代码

假设集合 price 有如下记录:

  1. { "_id": 1, "value": 10 }
  2. { "_id": 2, "value": 80 }
  3. { "_id": 3, "value": 50 }

value 不等于 50 的记录。

  1. const $ = db.command.aggregate
  2. db.collection('price').aggregate()
  3. .project({
  4. matched: $.neq(['$value', 50])
  5. })
  6. .end()

返回结果如下:

  1. { "_id": 1, "matched": true }
  2. { "_id": 2, "matched": true }
  3. { "_id": 3, "matched": false }