'MongoDB average of several fields in a new field in a document

Here is my document in MongoDB:

enter image description here

The Overall field is empty as you can see. What I'm trying to do is the overall field automatically gets Defence Shoot Pass Dribble and Speed fields and calculate the average value of them and put it there.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source