【发布时间】:2018-10-05 16:35:24
【问题描述】:
我一直在尝试使用最新的 C# 驱动程序执行 MongoDB graphLookup,该驱动程序使用 AggregateFluentExtensions。根据documentation: 该方法接收到一系列我无法找到工作的参数。
有人用过吗?可以帮我举个例子吗?
这是我的聚合的 json 版本:
db.getCollection("Item").aggregate(
[
{
"$project" : {
"itemMasterId" : 1.0,
"parentItemId" : 1.0
}
},
{
"$graphLookup" : {
"from" : "Item",
"startWith" : "$itemMasterId",
"connectFromField" : "itemMasterId",
"connectToField" : "parentItemId",
"as" : "ancestors",
"maxDepth" : 10,
"depthField" : "depthField",
"restrictSearchWithMatch" : {
"locationId" : 26
}
}
},
{
"$project" : {
"itemMasterId" : 1.0,
"parentItemId" : 1.0,
"children.itemMasterId" : 1,
"children.parentItemId" : 1
}
}
]
);
谢谢!
【问题讨论】:
标签: c# mongodb aggregation-framework