我遇到了问题
“无法从BSON类型字符串转换为日期”
用于运行以下聚合查询:
db.test.aggregate(
// Pipeline
[
// Stage 1
{
$match: {"Total Number Of CM": { $exists: true }}
},
// Stage 2
{
$project: {
_id : 0,
Date: { $dateToString: { format: "%Y-%m-%d", date: "$CollectionTime" } },
DeviceName: 1,
ResourceName: 1,
"Total Number Of CM": 1,
"Online Number Of CM": 1,
"Offline Number Of CM": 1,
}
},
// Stage 3
{
$group: {
"_id": { Date: "$Date"},
ResourceName: { $first: "$ResourceName" },
DeviceName: { $first: "$DeviceName" },
TotalCM: { $avg: "$Total Number Of CM" },
OnlineCM: { $avg: "$Online Number Of CM" },
offlineCM: { $avg: "$offline Number Of CM" }
}
}
]
);
请,我需要帮助来解决这个问题。样本看起来像:
{
"DeviceName" : "OLT0",
"ResourceName" : "OLT/Frame:1/Slot:1/Port:0",
"CollectionTime" : ISODate("2016-11-03T13:35:00.000+01:00"),
"GranularityPeriod" : NumberLong("5"),
"Total Number Of CM" : NumberLong("26"),
"Online Number Of CM" : NumberLong("22"),
"Offline Number Of CM" : NumberLong("4")
}