diff options
-rw-r--r-- | cli/tsc/dts/lib.deno.unstable.d.ts | 4 | ||||
-rw-r--r-- | ext/kv/01_db.ts | 8 |
2 files changed, 12 insertions, 0 deletions
diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts index 4bc0fed45..9c4bd5d2c 100644 --- a/cli/tsc/dts/lib.deno.unstable.d.ts +++ b/cli/tsc/dts/lib.deno.unstable.d.ts @@ -1840,6 +1840,10 @@ declare namespace Deno { */ mutate(...mutations: KvMutation[]): this; /** + * Shortcut for creating a sum mutation. + */ + sum(key: KvKey, n: bigint): this; + /** * Add to the operation a mutation that sets the value of the specified key * to the specified value if all checks pass during the commit. */ diff --git a/ext/kv/01_db.ts b/ext/kv/01_db.ts index 38dcb4ae0..16099c225 100644 --- a/ext/kv/01_db.ts +++ b/ext/kv/01_db.ts @@ -211,6 +211,14 @@ class AtomicOperation { return this; } + sum(key: Deno.KvKey, n: bigint): this { + return this.mutate({ + type: "sum", + key, + value: new KvU64(n), + }); + } + mutate(...mutations: Deno.KvMutation[]): this { for (const mutation of mutations) { const key = mutation.key; |