Sql 如何在mongodb上检索空查找条目?
我有一个查询,它为我提供了我想要的加入:Sql 如何在mongodb上检索空查找条目?,sql,mongodb,robo3t,Sql,Mongodb,Robo3t,我有一个查询,它为我提供了我想要的加入: db.summoners.aggregate([ { "$match": { "nick":"Luispfj" } }, { "$unwind": "$matches" }, { "$lookup": { "from":"matches", "localField":"matches.gameId", "foreignField":"gameI
db.summoners.aggregate([
{ "$match": { "nick":"Luispfj" } },
{ "$unwind": "$matches" },
{
"$lookup": {
"from":"matches",
"localField":"matches.gameId",
"foreignField":"gameId",
"as":"fullMatches"
}
},
{ "$unwind": "$fullMatches" },
{
"$group": {
"_id": null,
"matches": { "$push":"$fullMatches" }
}
}
])
但是当我运行unwind函数时,空条目就消失了。我如何检索它们(如果可能,使用它们各自的“gameId”
另外,是否有方法仅检索匹配数组,而不是它创建的“空id对象”的子属性?
$unwind
采用可选字段preserveNullAndEmptyArrays
,默认情况下为false
。如果将其设置为true,unwind将输出空文档
{
"$unwind": {
path: "$fullMatches",
preserveNullAndEmptyArrays: true
}
},