I have a mongo document with several fields -
User: { paid_visits: 10, free_visits: 10, totalLength: 120, avgRevenue: 4.4 }
I update the visits and the total length automatically, but in order to compute the avgRevenue, I need to do a computation based on totalLength, paid_visits and free_visits.
Currently I need to get the user, compute the avgRevenue, and then update it.
What I would like to do is to update the avgRevenue every time I update any other field. How can I do that?