1.语句
db.getCollection("authLog").distinct(
"authType",
{
"createTime":{$gte:new Date(2022,1,1)},
"createTime":{$lte:new Date(2023,2,1)},
"authType":{$ne:null},
"stage":{$eq:"AUTH"}
}
)
db.getCollection("authLog").createIndex({"authType":1,"createTime":1})
db = db.getSiblingDB("cims");
db.getCollection("authLog").aggregate(
[
{
"$match" : {
"createTime" : {
"$gte" : ISODate("2022-01-31T16:00:00.000+0000")
},
"authType" : {
"$ne" : null
},
"stage" : {
"$eq" : "AUTH"
}
}
},
{
"$group" : {
"_id" : "$authType",
"authCount" : {
"$sum" : 1.0
},
"authType" : {
"$first" : "$authType"
},
"createTime" : {
"$first" : "$createTime"
}
}
}
],
{
"allowDiskUse" : false
}
);
版权声明:本文为qq_42977853原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。