Delete the value for the given key from the database. If no value exists for the key, this operation is a no-op.
The key to delete.
Optional
signal: AbortSignalA promise resolving to an object containing a boolean indicating whether the operation was successful, and the versionstamp of the deleted key-value entry.
Retrieve the value and versionstamp for the given key from the database in the form of a KvEntryMaybe. If no value exists for the key, the returned entry will have a null value and versionstamp.
Optional
signal: AbortSignalRetrieve multiple values and versionstamp from the database in the form of an array of KvEntryMaybe objects. The returned array will have the same length as the keys array, and the entries will be in the same order as the keys. If no value exists for a given key, the returned entry will have a null value and versionstamp.
Optional
signal: AbortSignalRetrieve a list of keys in the database. The returned list is a NanoStream which can be used to iterate over the entries in the database. Each list operation must specify a selector which is used to specify the range of keys to return. The selector can either be a prefix selector, or a range selector:
Optional
options: KvListOptionsThe options argument can be used to specify additional options for the list operation. See the documentation for KvListOptions for more information.
Listen for queue values to be delivered from the database queue, which were enqueued with AtomicOperation.enqueue, you can spcify which keys to listen to.
You need to use AtomicOperation.dequeue to dequeue values from the queue after you have received and processed them, or you will get duplicates in next time you call this method.
The keys to listen to.
A readable stream of key-value pairs.
Set the value for the given key in the database. If a value already exists for the key, it will be overwritten.
Optionally an expireIn option can be specified to set a time-to-live (TTL) for the key. The TTL is specified in milliseconds, and the key will be deleted from the database at earliest after the specified number of milliseconds have elapsed. Once the specified duration has passed, the key may still be visible for some additional time. If the expireIn option is not specified, the key will not expire.
The key to set.
The value to set.
Optional
options: { expireIn?: number; signal?: AbortSignal }Options for the set operation.
Optional
expireIn?: numberThe number of milliseconds after which the key-value entry will expire.
Optional
signal?: AbortSignalGet a subspace of the database, operating on all key with the given prefix.
Watch for changes to the given keys in the database. The returned stream is a NanoStream that emits a new value whenever any of the watched keys change their versionstamp. The emitted value is an array of KvEntryMaybe objects, with the same length and order as the keys array. If no value exists for a given key, the returned entry will have a null value and versionstamp.
The returned stream does not return every single intermediate state of the watched keys, but rather only keeps you up to date with the latest state of the keys. This means that if a key is modified multiple times quickly, you may not receive a notification for every single change, but rather only the latest state of the key.
An array of keys to watch for changes.
Create a new AtomicOperation object which can be used to perform an atomic transaction on the database. This does not perform any operations on the database - the atomic transaction must be committed explicitly using the AtomicOperation.commit method once all checks and mutations have been added to the operation.