我的文档结构
这是我正在运行的。。。。你知道吗
query = self._database.suiteruns.aggregate([
{
"$project": {
"name": 1,
"user": 1,
"endTime":1,
"duration": 1,
"testCases": 1,
"verdict": 1
}
},
{
"$match": {
"user": user_id
}
},
{
"$group": {
"_id": "$name",
"count": {
"$sum": "$name"
}
}
},
{
"$sort": {
"updatedTime": -1
}
}
])
运行上述查询后的结果
[
{
u'count': 0,
u'_id': u"Minor GC003"
}
.
.
.
. some more objects like this(without the fields mentioned in $project)
]
*预期结果*
[
{
"verdict": "",
"testCases" : [{}],
.
.
. (other fields)
}]
我想对name字段进行分组,并按用户进行匹配,还希望得到其他字段,如我在$project中提到的,但仍然没有得到其他字段。 任何帮助/讨论都会很好。。。
你可以试着跟着方式:-你知道吗
结果将是
希望这会有帮助。有关详细信息,请参阅$group。你知道吗
相关问题 更多 >
编程相关推荐