Home > database >  Mongoose aggregate group cond error The $cond accumulator is a unary operator
Mongoose aggregate group cond error The $cond accumulator is a unary operator

Time:09-16

 
{
$group: {
_id: {
Uid: '$uid,
Role: '$role'
},
Nickname: {$cond: [{$eq:} [$role, 2], '$nickname', 'test']},
}
}

An error
 
The $cond accumulator is a unary operator

What's wrong with the don't know, bosses, please help to look at, thank you very much

CodePudding user response:

Has been solved, in the $
used in the project
 
{
$project: {
_id: 0,
Uid: '$uid,
Role: '$role',
Nickname: {$cond: [{$eq:} [$role, 2], '$nickname', 'test']},
}
}
  • Related