Skip to content

$nin

Checks whether a value does not exist in an array.

Syntax

{ "$nin": [ <expression>, <arrayExpression> ] }

Example

Input

{ "roles": ["viewer", "auditor"] }

Stage

{ "$project": { "isAdmin": { "$nin": ["admin", "$roles"] } } }

Output

{ "isAdmin": true }