It’s the tips on MongoDB Compass “Unrecognized option to $lookup: let”
[{
$lookup: {
from: 'RoleEntity',
let: {
anotherRoleId: "$roleId"
},
pipeline: [{
$match: {
"serverId": 3,
"lastLoginTime": {
$lt: 1588435200000
},
"createTime": {
$gte: 0,
$lte: 1588435199999
}
}
},
{
$match: {
$expr: {
$eq: ["$roleId", "$$anotherRoleId"]
}
}
},
],
as: 'roles'
}}, {
$match: {
"roles": {
$gt: {
$size: 0
}
}
}}, {
$group: {
_id: "$curChapterId",
count: {
$sum: 1
}
}}]
How can i query without the ‘let’ label?
The pseudo-SQL statement what i want is:
SELECT curChapterId,count(*) FROM RleChapterEntity where roleId IN (SELECT roleId from RoleEntity where ...) GROUP BY curChapterId
Very thanks for your help.