{ "_id" : ObjectId("54a9542e32219b1894f38199"),
"sesion" : "vw01q45m4c5ir45opjhncun-04012015155437",
"prio" : 0,
"ptun" : 78.48,
"meta" : {
"id_array" : 0,
"deption" : "Main Type 1",
"des" : "MAL",
"reg" : "sub type 1",
"princ" : "78,48",
"Xref" : "ref external ID",
"XNRF" : false
},
"hora" : new Date("4/1/2015 15:54:38")
}
我想获得一个定义的“id_array”字段,所有以这种方式分组的对象。对于相同的“deption”,“reg”将文档用较低的ptun字段,但我得到0结果。
我的代码(我真的是这个框架的新手)。任何帮助将非常感激
valorint = 52
Dim operacionmatch2 = New BsonDocument() From { _
{"$match", New BsonDocument() From { _
{"meta.id_array", valorint}}}}
Dim groupFamiliesOperation2 = New BsonDocument() From { _
{"$group", New BsonDocument() From { _
{"_id", New BsonDocument() From { _
{"deption", "$meta.deption"}, {"reg", "$meta.reg"} _
}}, _
{"Minimo", New BsonDocument() From { _
{"$min", "$meta.ptun"} _
}}}}}
Dim sortidOperation = New BsonDocument() From { _
{"$sort", New BsonDocument() From { _
{"id_array", 1} _
}} _
}
Dim j As AggregateResult
j = transactions.Aggregate(operacionmatch2, groupFamiliesOperation2, sortidOperation)
Console.WriteLine(" inicia consulta " & Now())
For Each jj In j.ResultDocuments
Dim b = 3
Console.WriteLine(jj.ToBsonDocument())
Next