Created
January 22, 2014 12:46
-
-
Save 1ambda/8558143 to your computer and use it in GitHub Desktop.
Mongoose Average Query Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var CpuUtilization = require('./models/cpu_utilization'); | |
CpuUtilization.aggregate({ | |
// $match: { instance_id: { $gte: 21 }} | |
$match : { | |
instance_id : 'i-2d800b2a', | |
time_stamp : { | |
// $lt : new Date('Tue Jan 21 2014 19:31:00 GMT+0900 (대한민국 표준시)') | |
$lt : new Date('2014-01-21 10:31:00.000Z') | |
} | |
} | |
}).group({ | |
_id : '$instance_id', | |
markAvg : { | |
$avg : '$average' | |
} | |
}).exec(function(err, res) { | |
if (err) { | |
console.log(err); | |
} else { | |
console.log(res); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment