[MogoDB] Calling functions/operators in the Aggregation Expression Language

Calling functions/operator in the aggregation expression language

How did I encounter this?

When learning on $redact, I saw the following case:

{$gte: ['$imdb.rating', 7]},

Syntax

In the aggregation expression language, operators like $gte are treated as functions. They take arguments in an array

db.movies.aggregate([

{

$redact: {

$cond: {

if: {$gte: ['$imdb.rating', 7]},

then: '$$KEEP',

else: '$$PRUNE'

}

}

}

])


Comments