Python EVE 聚合不工作
Python EVE aggregation not working
我正在使用 Eve 为 MongoDB 创建 RESTful API。也许我做错了什么,但我不明白为什么 Eve 没有返回汇总结果。下面是我的域:
DOMAIN = {
'heartbeats': {
'schema': {
'user': {
'type': 'objectid',
'required': True,
},
'device': {
'type': 'objectid',
'required': True,
},
'pir': {
'type': 'integer'
},
'camera': {
'type': 'integer'
},
'image': {
'type': 'media',
'required':False
}
}
},
'chart1' : {
'datasource':{
'source' : 'heartbeats',
'aggregation' : {
'pipeline': [
{"$group" : {"_id":"$user", "count" : {"$sum" : 1}}}
]
}
}
}
}
当从浏览器查询时,我只得到所有记录,而不是汇总结果。
为什么我没有得到汇总结果?
你用的是哪个 Eve 版本? MongoDB 聚合框架支持目前在开发分支上。如果您使用的是任何稳定版本(最新的 v0.6.4),您将不会获得聚合支持。尝试安装开发分支。
我正在使用 Eve 为 MongoDB 创建 RESTful API。也许我做错了什么,但我不明白为什么 Eve 没有返回汇总结果。下面是我的域:
DOMAIN = {
'heartbeats': {
'schema': {
'user': {
'type': 'objectid',
'required': True,
},
'device': {
'type': 'objectid',
'required': True,
},
'pir': {
'type': 'integer'
},
'camera': {
'type': 'integer'
},
'image': {
'type': 'media',
'required':False
}
}
},
'chart1' : {
'datasource':{
'source' : 'heartbeats',
'aggregation' : {
'pipeline': [
{"$group" : {"_id":"$user", "count" : {"$sum" : 1}}}
]
}
}
}
}
当从浏览器查询时,我只得到所有记录,而不是汇总结果。
为什么我没有得到汇总结果?
你用的是哪个 Eve 版本? MongoDB 聚合框架支持目前在开发分支上。如果您使用的是任何稳定版本(最新的 v0.6.4),您将不会获得聚合支持。尝试安装开发分支。