is it possible in MongoDB to have default values in nested arrays or objects?
I use the following schema for a nested object:
However, when I retrieve this schema on the frontend, with “findOne”, “used” does not have a default value at all:
I would like to prepopulate this array with a default value, if it is empty, to access it with the JS frontend without always checking if this array exists.
Do you have any idea how I could achieve this, or if this would even be a good practice concerning data modelling?