码迷,mamicode.com
首页 > 数据库 > 详细

Mongodb查询语句

时间:2018-05-14 13:46:41      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:dna   tst   day   reg   ODB   tostring   moni   cti   mat   

db.getCollection(‘RpcMonitor_Request‘).find(
{
"RequestStartTime" :
{
$gt :ISODate("2018-05-14 02:00"),
$lt:ISODate("2018-05-14 04:00")
},
"_id":ObjectId("5af8fc5809d8d057f6a734e4")
})


db.getCollection(‘RpcMonitor_Request‘).aggregate(
[
{
$group:
{
RequestCount:{$sum:1},
_id:
{
"RequestDay": { $dateToString: { format: "%Y-%m-%d", date: "$RequestStartTime" } },
"RequestTypeName":"$RequestTypeName",
"RequestMethodName":"$RequestMethodName"
}
}
}
])

db.getCollection(‘RpcMonitor_Request‘).aggregate(
[
{
$group:
{
RequestCount:{$sum:1},
_id:
{
"RequestDay": { $dateToString: { format: "%Y-%m-%d", date: "$RequestStartTime" } },
"RequestTypeName":"$RequestTypeName",
"RequestMethodName":"$RequestMethodName"
}
}
},
{ $project : {"_id": 0, "RequestDay" : "$_id.RequestDay", "RequestTypeName" : "$_id.RequestTypeName", "count" : "$RequestCount","RequestMethodName":"$_id.RequestMethodName"}}
])


db.getCollection(‘RpcMonitor_Request‘).aggregate(
[
{$match:{
"RequestStartTime" :
{
$gt :ISODate("2018-05-14 02:00"),
$lt:ISODate("2018-05-14 04:00")
}
}},
{
$group:
{
RequestCount:{$sum:1},
_id:
{
"RequestDay": { $dateToString: { format: "%Y-%m-%d", date: "$RequestStartTime" } },
"RequestTypeName":"$RequestTypeName",
"RequestMethodName":"$RequestMethodName"
}
}
},
{ $project : {"_id": 0, "RequestDay" : "$_id.RequestDay", "RequestTypeName" : "$_id.RequestTypeName", "count" : "$RequestCount","RequestMethodName":"$_id.RequestMethodName"}}
])

Mongodb查询语句

标签:dna   tst   day   reg   ODB   tostring   moni   cti   mat   

原文地址:https://www.cnblogs.com/yjq-code/p/9035644.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!