Hello everyone,
from what I understand, if a collection is sharded on a key that is not the _id field, there is no guarantee of unicity for the _id field across different shards (https://docs.mongodb.com/manual/core/sharding-shard-key/#unique-indexes).
Then, I don’t understand this statement about the update_one operator:
- If you don’t specify
upsert: true
, you must include an exact match on the_id
field or target a single shard (such as by including the shard key in the filter).
I understand why the shard key is needed, in order to ensure the operation really updates 1 single item. But why can it be replaced by the _id?
Thanks !