I can’t find any documentation that specifies how $unset works in the embedded documents array context.
I was reading a S.O. post (which I can’t link because I can’t find it again) that seemed to indicate that there are some options that have to be passed to make the unset work on multiple embedded documents.
I see that there are some update options - but they don’t seem useful.
Please provide sample documents that we can cut-n-paste directly into our system.
If I understand correctly gizmos is an array of objects. Some of the objects have a field named color. You want to remove the field color from all objects.
I am not too sure if there is a way to do it directly. One approach that could work is using the $set with aggregation syntax:
1 - I would use $map on gizmos to produce a temporary _gizmos by using $objectToArray
2 - Then a $map on _gizmos that uses $filter on each element that remove k:color
3 - A final $map that uses $arrayToObject on _gizmos elements to reconstruct an updated gizmos