diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/kv/01_db.ts | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/ext/kv/01_db.ts b/ext/kv/01_db.ts index 1a7b27dac..da29a0952 100644 --- a/ext/kv/01_db.ts +++ b/ext/kv/01_db.ts @@ -211,14 +211,6 @@ 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; @@ -249,6 +241,21 @@ class AtomicOperation { return this; } + sum(key: Deno.KvKey, n: bigint): this { + this.#mutations.push([key, "sum", serializeValue(new KvU64(n))]); + return this; + } + + min(key: Deno.KvKey, n: bigint): this { + this.#mutations.push([key, "min", serializeValue(new KvU64(n))]); + return this; + } + + max(key: Deno.KvKey, n: bigint): this { + this.#mutations.push([key, "max", serializeValue(new KvU64(n))]); + return this; + } + set(key: Deno.KvKey, value: unknown): this { this.#mutations.push([key, "set", serializeValue(value)]); return this; |