mongodb分页插件 mongodb同时实现分组和分页
mongodb同时实现分组和分页
参考代码:
var pipeline =[
{
$match: {
sjbh: {$gte: beginDate, $lte:endDate}
}
},
{
$group: {
_id: "$gsbh",
totaltxl: {$sum: { $cond: { if: { $ne: [ "$totalnum","" ] }, then:"$txl" , else: 0 }}},
totalbmynum: {$sum: "$bmynum"}
}
},
{
$project: {
_id: 0,
gsbh: "$_id",
totaltxl: "$totaltxl",
totalbmynum: "$totalbmynum",
ratio: { $divide: [ "$totalbmynum", { $cond:{if: { $eq: [ "$totaltxl",0 ] }, then:1 , else: "$totaltxl" }}] }
}
},
{$sort: {ratio: -1}},
{$limit: 5}
{$skip : 5}
]
opts.dbs.csdb.collection("permydfx").aggregate(pipeline).......
MongoDB 2d空间索引怎么分页显示
您好,我来为您解答,写法如下:
现在MongoDB还不支持。参见tickets SERVER-3925 和 SERVER-5800。
你可以在JIRA上跟踪这个feature, 也可以给它们投票。
如果我的回答没能帮助您,请继续追问。
mongodb3.0分片使用mongos没有权限
"not authorized on admin to execute command { addShard: "shard1/192.168.62.153:17053" }", "code" : 13}
你确定权限设置都ok?
dbdao.com