How to create a field that contains values formulated with values of other fields?

I am not aware of any “formula” type field in MongoDB. May be mongoose can do it for you.

In plain mongo, you may

  1. update the field like I shared
  2. compute the field with a projection every time you find or aggregate
  3. create a view with the same aggregation as #2 above

#1 is the fastest but takes more space, the computed value can be indexed, it has a high risk of becoming out of sync if documents are manipulated without your API