mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
feat(kv): AtomicOperation#sum (#18704)
This commit is contained in:
parent
1bca994143
commit
2184103a5e
2 changed files with 12 additions and 0 deletions
4
cli/tsc/dts/lib.deno.unstable.d.ts
vendored
4
cli/tsc/dts/lib.deno.unstable.d.ts
vendored
|
@ -1839,6 +1839,10 @@ declare namespace Deno {
|
||||||
* for {@linkcode Deno.KvMutation}.
|
* for {@linkcode Deno.KvMutation}.
|
||||||
*/
|
*/
|
||||||
mutate(...mutations: KvMutation[]): this;
|
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
|
* 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.
|
* to the specified value if all checks pass during the commit.
|
||||||
|
|
|
@ -211,6 +211,14 @@ class AtomicOperation {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sum(key: Deno.KvKey, n: bigint): this {
|
||||||
|
return this.mutate({
|
||||||
|
type: "sum",
|
||||||
|
key,
|
||||||
|
value: new KvU64(n),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
mutate(...mutations: Deno.KvMutation[]): this {
|
mutate(...mutations: Deno.KvMutation[]): this {
|
||||||
for (const mutation of mutations) {
|
for (const mutation of mutations) {
|
||||||
const key = mutation.key;
|
const key = mutation.key;
|
||||||
|
|
Loading…
Reference in a new issue