Supported platforms: Mini Program 2.7.4, Cloud Functions 0.8.1, Web
Aggregate operator. Matches two values; returns true if they are equal, otherwise returns false.
Parameters
value: Expression[]
[<value1>, <value2>]
Return Values
Object
API Description
The syntax is as follows:
db.command.aggregate.eq([<value1>, <value2>])
Example Code
Suppose the price collection contains the following records:
{ "_id": 1, "value": 10 }
{ "_id": 2, "value": 80 }
{ "_id": 3, "value": 50 }
Find the record where value equals 50.
const $ = db.command.aggregate
db.collection('price').aggregate()
.project({
matched: $.eq(['$value', 50])
})
.end()
The returned result is as follows:
{ "_id": 1, "matched": false }
{ "_id": 2, "matched": false }
{ "_id": 3, "matched": true }