I think I’m going to change my data model to avoid the problem. Luckily I have the luxury to change it. A more convenient data model will look like:
{
id: "docId",
colorsDefault: "red",
colors: [
{value: "red"},
{value: "white"},
{value: "blue"}
]
}
Now the update command is obvious. I just need to change a single field and no array elements.
{
$set: {colorsDefault: "blue"}
}
Still, I wonder if it is possible to remove the property default=true from one array element while atomically updating another element.