问题
I have the following json:
{
"statement":{
"result":{
"duration":"PT0.552S",
"completion":true,
"success":false
}
},
"statement":{
"result":{
"duration":"PT0.552S",
"completion":true,
"success":false
}
},
"statement":{
"result":{
"duration":"PT0.552S",
"completion":true,
"success":false
}
}
}
How can I write a mongo aggregator to getting the statement -> result -> duration time format that now in ptms string to seconds?
I need something like:
[
1131,
648,
1678,
.....
.....
]
Here each number is the duration that is converted into seconds.
Here : http://docs.mongodb.com/manual/reference/operator/aggregation/hour I can see : "date" : ISODate("2014-01-01T08:15:39.736Z") but how to use it for ptms time format?
I am encoding these aggregators and passing in query parameters to server to get the result. So how to use ISODate in query parameter ? How can I encode it? say like encode the following json format and pass it in GET query parameters:
{
"$project": {
"duration": "$ISODate('$statement.result.duration')"
}
}
来源:https://stackoverflow.com/questions/51152423/mongodb-3-4-7-aggregation-convert-ptms-time-to-seconds