I have a mongo collection, and an example of the document that looks like this:
"_id" : ObjectId("5a0625b5849c823f77ba8d2b"),
"start_datetime" : ISODate("2017-07-01T00:00:00Z"),
"cdn_400_%_lin_hls" : 0,
"cdn_400_%_lin_ss" : 0,
"cdn_400_%_vod_hls" : 0
I am trying to aggregate based on a match on the "start_datetime" field, which contains ISODate date object in it, using javascript. Below is my code:
var MongoClient = require('mongodb').MongoClient;
var url = 'mongodb://localhost:27017/mydb';
MongoClient.connect(url, function(err, db) {
db.collection('my_collection', function(err, collection) {
collection.aggregate(
{'$match':{'start_datetime': new Date("2017-07-01T00:00:00Z")}},
function(err, data){
if(err)
throw err;
console.log(data);
}
);
});
});
Below is the result when I ran the script:
_id: 5a0625b5849c823f77ba8d2b,
start_datetime: Fri Jun 30 2017 18:00:00 GMT-0600 (MDT),
'cdn_400_%_lin_hls': 0,
'cdn_400_%_lin_ss': 0,
'cdn_400_%_vod_hls': 0,
My questions:
Why did the result show start_datetime: Fri Jun 30 2017 18:00:00 GMT-0600 (MDT) instead of "start_datetime" : ISODate("2017-07-01T00:00:00Z")?
How can I make it so that the result shows "start_datetime" : ISODate("2017-07-01T00:00:00Z"), which is what's actually saved in the collection (basically, I want the ISODate object not the formatted string of the date)?