语法定义
$lookup:
{
from: <collection to join>,
localField: <field from the input documents>,
foreignField: <field from the documents of the "from" collection>,
as: <output array field>
}
}
说明
field | description |
---|---|
from | 联合哪张表 |
localField | 本记录中表的字段 |
forgeginField | 被联合表的字段 |
as | 结果输出的字段名称 |
demo
let cond = [
{
$addFields: {
project_id: {
$convert: {
input: "$projectid",
to: "objectId",
onError: "test", // Option