【发布时间】:2022-01-15 07:36:03
【问题描述】:
我尝试创建一个连接查询并从我的结果中排除 _id 字段
stage_lookup_comments = {
"$lookup": {
"from": "products",
"localField": "product_codename",
"foreignField": "codename",
"as": "product",
}
}
pipeline = [
{ "$match": {
"category":category,
"archived_at":{"$eq": None}
}
},
stage_lookup_comments
]
array = await db[collection].aggregate(pipeline).to_list(CURSOR_LIMIT)
return array
我不知道将"_id": 0 参数添加到我的查询的语法是什么。
【问题讨论】:
-
在最后添加一个
$project阶段如何通过_id: false排除_id字段?