Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
None
-
None
-
None
-
ALL
Description
Hi
yii::$app->mongodb->GetCollection('sessions')->Aggregate([ |
[
|
'$lookup' => [ |
'from' => 'users', |
'localField' => '_userId', |
'foreignField' => '_id', |
'let' => ['sRoleId' => '$_roleId'], |
'pipeline' => [ |
[
|
'$match' => [ |
'enable' => true, |
],
|
],
|
[
|
'$lookup' => [ |
'from' => 'roles', |
'pipeline' => [ |
[
|
'$match' => [ |
//'$expr' => ['$_id' => '$$sRoleId'], //Error |
//'$expr' => ['x' => 'y'], //Always is true and return all docs |
'$expr' => ['$eq' => ['$_id','$$sRoleId']], //OK |
],
|
],
|
],
|
'as' => 'role', |
],
|
],
|
],
|
'as' => 'user', |
],
|
],
|
]);
|