arangodb / arangojs

The official ArangoDB JavaScript driver.
https://arangodb.github.io/arangojs
Apache License 2.0
601 stars 107 forks source link

overwriteMode: "replace" doesn't seem to work in DocumentCollection.save() with conflicting keys #698

Closed lostpebble closed 3 years ago

lostpebble commented 4 years ago

As per the title, this doesn't seem to work:

quickCacheCollection.save(newData, { overwriteMode: "replace" });

I was getting the error returned:

unique constraint violated - in index primary of type primary over '_key'; conflicting key: my_key_here

I was using the new overwriteMode because I see the overwrite option is now deprecated. But, it seems the only way to get a save() to just replace the data that's there even if a key already exists, is to still pass the old option. This works:

quickCacheCollection.save(newData, { overwriteMode: "replace", overwrite: true });
pluma commented 3 years ago

Which version of ArangoDB are you using? The overwriteMode option was added fairly recently.

lostpebble commented 3 years ago

Currently using 3.6.7. Is this a > 3.7 feature?

pluma commented 3 years ago

Looks like it was added in 3.7: https://www.arangodb.com/docs/stable/release-notes-new-features37.html#insert-update-and-insert-ignore

FWIW the deprecation notice in arangojs says that overwrite is deprecated in ArangoDB 3.7. Sadly there's no way to make this any more explicit as arangojs versions are not tied 1-to-1 to ArangoDB (i.e. arangojs will work with most of the recent releases of ArangoDB but documentation will generally track the latest version only).

Feel free to reopen this issue if you need any additional information.