• Mongodb查询语句


    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"}}
    ])

    var group = new BsonDocument
    {
    { "_id", new BsonDocument
    {
    { "Month", new BsonDocument("$month", "$RequestStartTime") },
    { "Day", new BsonDocument("$dayOfMonth", "$RequestStartTime") },
    { "Year", new BsonDocument("$year", "$RequestStartTime") },
    { "RequestMethodName", "$RequestMethodName" },
    { "RequestTypeName", "$RequestTypeName" },
    { "IsSuccess", "$IsSuccess" },
    }
    },
    { "Count", new BsonDocument("$sum", 1) } };
    var project = new BsonDocument
    {
    {
    "_id",0
    },
    {
    "RequestMethodName","$_id.RequestMethodName"
    },
    {
    "RequestTypeName","$_id.RequestTypeName"
    },
    {
    "IsSuccess","$_id.IsSuccess"
    },
    {
    "TotalCount","$Count"
    }
    };

    var group = new BsonDocument
    {
    { "_id", new BsonDocument
    {
    { "RequestTime",new BsonDocument{
    {
    "$dateToString",new BsonDocument{
    { "format","%Y-%m-%d %H:%M"},
    {"date", "$RequestStartTime" }
    }
    }
    } },
    { "Day", new BsonDocument("$dayOfMonth", "$RequestStartTime") },
    { "Year", new BsonDocument("$year", "$RequestStartTime") },
    { "RequestMethodName", "$RequestMethodName" },
    { "RequestTypeName", "$RequestTypeName" },
    { "IsSuccess", "$IsSuccess" },
    }
    },
    { "Count", new BsonDocument("$sum", 1) } };

  • 相关阅读:
    F. 数学上来先打表
    LibreOJ β Round #2
    noip飞扬的小鸟
    jxoi2017
    分块算法
    Chino的数列
    cf 613E
    cf 126D
    cf 542E
    cf 512D
  • 原文地址:https://www.cnblogs.com/yjq-code/p/9035644.html
Copyright © 2020-2023  润新知