For certain use-cases (particularly when keys are content-hashes of values), it'd be nice to be able to combine an existence check + the insertion into one operation. When the ifNotExists flag is set in put, the insertion will stop if it detects that the closest node has the same key as the one being inserted. With this approach, only one traversal is required to accomplish the above workflow.
The PR:
Adds the ifNotExists flag to db.put
Adds three tests (in test/basic.js) to ensure that this behavior works correctly (including in the presence of conflicts).
For certain use-cases (particularly when keys are content-hashes of values), it'd be nice to be able to combine an existence check + the insertion into one operation. When the
ifNotExists
flag is set input
, the insertion will stop if it detects that the closest node has the same key as the one being inserted. With this approach, only one traversal is required to accomplish the above workflow.The PR:
ifNotExists
flag todb.put
test/basic.js
) to ensure that this behavior works correctly (including in the presence of conflicts).