//查询语句
db.collection('ProgramOfPerson').aggregate()
.match(_.and([{
_openid: '*'
}, {
like: 1
}]))
.project({
programid: 1
})
.lookup({
from: 'Program',
let: {
id: '$programid'
},
pipeline: $.pipeline()
.match(_.expr($.and([
$.eq(['$_id', '$$id']),
])))
.project({
_id:0,
title: 1,
datetime: 1,
content: $.substrCP(['$content', 0, 100])
})
.done(),
as: 'a'
})
.end()
[{
"_id": "*",
"programid": "*",
"a": [
{
"datetime": "2022/11/22 12:33:26",
"title": "24",
"content": "24\n"
}
]
}]
将上面的转为下面的
[{
"_id": "*",
"programid": "*",
"datetime": "2022/11/22 12:33:26",
"title": "24",
"content": "24\n"
}]
https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.lookup.html#%E7%A4%BA%E4%BE%8B
请各位大佬帮忙看看,感谢