Mongodb duplicate Unique index value

It makes a lot of sense. But in mongosh and js, I never encounter this issue because the JSON parser only keeps the last value:

node> d = {"d":300,"e":"Q","e":"X","e":"P"}
{ d: 300, e: 'P' }

Which is a node feature I use a lot to update a copy of an object:

original = { foo : 1 , bar : 2 }
updated_copy = { ... original , bar : 3 }
1 Like