Reputation: 3606
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 do I convert them to numbers without saving in actual collection so I can use them in $project (aggregation) and later use in $group to calculate $avg?
db.checkpointstest3.aggregate([
{$unwind: "$cpu"}])
I have correct $group , but it works on numbers not strings
Upvotes: 1
Views: 1471