Hi
Can some one tell me the correct way to do this:
I got this collection:
{
"_id": {
"$oid": "653c626b6ae0997703ddb119"
},
"count": 39028,
"totalSize": 10014720
},
need to add a new field
db.collection.updateMany({}, { $set: { "avgValue": "$totalSize" / "$count"} } )
I’m getting this result:
{
"_id": {
"$oid": "653c626b6ae0997703ddb119"
},
"count": 39028,
"totalSize": 10014720,
"avgSize": {
"$numberDouble": "NaN"
}
},
And I just need:
{
"_id": {
"$oid": "653c626b6ae0997703ddb119"
},
"count": 39028,
"totalSize": 10014720,
"avgSize": 256.60346418
}
Thanks