Enum

insert-mode

Selects the behavior for an insert when the new key matches an existing key.

A KV store maintains the property that its keys are unique from each other. If an insert has a key that doesn't match any key already in the store, then the pair of the key and the new value is inserted into the store. However, if the insert's key does match a key already in the store, then no new key-value pair is inserted, and the insert's insert-mode.mode determines what it does instead.

enum insert-mode {
  overwrite,
  add,
  append,
  prepend,
}

Cases

CaseDescription
overwrite

Updates the existing key's value by overwriting it with the new value.

This is the default mode.

add

Fails, leaving the existing key's value unmodified.

With this mode, the insert fails with a code of kv-error.precondition-failed, and does not modify the existing value. Inserts with this mode will only “add” new key-value pairs; they are prevented from modifying any existing ones.

append

Updates the existing key's value by appending the new value to it.

prepend

Updates the existing key's value by prepending the new value to it.