aggregation framework - mongodb string to number -
i have document in mongodb 2.6.11 including array of string i.e.
{ cpu: [ '0', '2', '4', '0', '0', '2', '0', '4', '0' ], con: [ '232', '2396', '17082', '339', '5', '1738', '503', '4', '0' ] }
how convert them numbers without saving in actual collection can use them in $project (aggregation) , later use in $group calculate $avg?
db.checkpointstest3.aggregate([ {$unwind: "$cpu"}])
i have correct $group , works on numbers not strings
currently aggregation pipeline not allow type conversion, see jira ticket. if changing type of field not option, either have fall on map reduce query or write own aggregation using foreach
.
Comments
Post a Comment