2 ms·
Yep. Put an unique index on the collection too.
by edoceo 10y ago
Yep. Put an unique index on the collection too.
- petergeoghegan 10y agoI'm not sure that it's that simple in practice. MongoDB may fail to provide the same guarantees that Postgres UPSERT does, if not in theory then at least in practice. In other words, it seems like retrying within client code is necessary when the Wired Tiger storage engine happens to be in use: https://stackoverflow.com/questions/29305405/mongodb-impossible-e11000-duplicate-key-error-dup-key-when-upserting https://stackoverflow.com/questions/29305405/mongodb-impossi...