I know I can do something like this to update the field to a specific value:
db.coll.update({},{ $set: {'fieldName': 'fieldValue' } }, { multi:true });
However, I need to update the value of a field equal to the number of values in an array field of the same document. I know this probably requires aggregate function but am newer to Mongo and could use some help constructing the query. It also needs to be done for every document in the collection.