diff options
author | Luca Casonato <hello@lcas.dev> | 2023-03-30 20:57:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-30 20:57:21 +0200 |
commit | e888c3f534c6ce9574f1d57e5cc61573a046039e (patch) | |
tree | 3bb52d77e111142c372826bb2cfd38f49da90ef1 /cli/tsc | |
parent | 206c593519681a024409d9dd23ef55b1d13d938f (diff) |
feat(ext/kv): return versionstamp from set/commit (#18512)
This commit updates the `Deno.Kv` API to return the new commited
versionstamp for the mutated data from `db.set` and `ao.commit`. This is
returned in the form of a `Deno.KvCommitResult` object that has a
`versionstamp` property.
Diffstat (limited to 'cli/tsc')
-rw-r--r-- | cli/tsc/dts/lib.deno.unstable.d.ts | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts index 32f7aad5e..f4dab5663 100644 --- a/cli/tsc/dts/lib.deno.unstable.d.ts +++ b/cli/tsc/dts/lib.deno.unstable.d.ts @@ -1748,6 +1748,11 @@ declare namespace Deno { batchSize?: number; } + export interface KvCommitResult { + /** The versionstamp of the value committed to KV. */ + versionstamp: string; + } + /** **UNSTABLE**: New API, yet to be vetted. * * A check to perform as part of a {@linkcode Deno.AtomicOperation}. The check @@ -1787,11 +1792,13 @@ declare namespace Deno { * performed and the operation will fail. One can then retry the read-modify- * write operation in a loop until it succeeds. * - * The `commit` method of an atomic operation returns a boolean indicating + * The `commit` method of an atomic operation returns a value indicating * whether checks passed and mutations were performed. If the operation failed - * because of a failed check, the return value will be `false`. If the + * because of a failed check, the return value will be `null`. If the * operation failed for any other reason (storage error, invalid value, etc.), - * an exception will be thrown. + * an exception will be thrown. If the operation succeeded, the return value + * will be a {@linkcode Deno.KvCommitResult} object containing the + * versionstamp of the value committed to KV. * * @category KV */ @@ -1821,17 +1828,19 @@ declare namespace Deno { */ delete(key: KvKey): this; /** - * Commit the operation to the KV store. Returns a boolean indicating - * whether checks passed and mutations were performed. If the operation - * failed because of a failed check, the return value will be `false`. If - * the operation failed for any other reason (storage error, invalid value, - * etc.), an exception will be thrown. + * Commit the operation to the KV store. Returns a value indicating whether + * checks passed and mutations were performed. If the operation failed + * because of a failed check, the return value will be `null`. If the + * operation failed for any other reason (storage error, invalid value, + * etc.), an exception will be thrown. If the operation succeeded, the + * return value will be a {@linkcode Deno.KvCommitResult} object containing + * the versionstamp of the value committed to KV. * - * If the commit returns `false`, one may create a new atomic operation with + * If the commit returns `null`, one may create a new atomic operation with * updated checks and mutations and attempt to commit it again. See the note * on optimistic locking in the documentation for {@linkcode Deno.AtomicOperation}. */ - commit(): Promise<boolean>; + commit(): Promise<KvCommitResult | null>; } /** **UNSTABLE**: New API, yet to be vetted. @@ -1932,7 +1941,7 @@ declare namespace Deno { * await db.set(["foo"], "bar"); * ``` */ - set(key: KvKey, value: unknown): Promise<void>; + set(key: KvKey, value: unknown): Promise<KvCommitResult>; /** * Delete the value for the given key from the database. If no value exists |