summaryrefslogtreecommitdiff
path: root/ext/kv/01_db.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ext/kv/01_db.ts')
-rw-r--r--ext/kv/01_db.ts12
1 files changed, 7 insertions, 5 deletions
diff --git a/ext/kv/01_db.ts b/ext/kv/01_db.ts
index 70e4c7fca..e0c5335e6 100644
--- a/ext/kv/01_db.ts
+++ b/ext/kv/01_db.ts
@@ -111,14 +111,15 @@ class Kv {
[key, "set", value],
];
- const result = await core.opAsync(
+ const versionstamp = await core.opAsync(
"op_kv_atomic_write",
this.#rid,
checks,
mutations,
[],
);
- if (!result) throw new TypeError("Failed to set value");
+ if (versionstamp === null) throw new TypeError("Failed to set value");
+ return { versionstamp };
}
async delete(key: Deno.KvKey) {
@@ -255,15 +256,16 @@ class AtomicOperation {
return this;
}
- async commit(): Promise<boolean> {
- const result = await core.opAsync(
+ async commit(): Promise<Deno.KvCommitResult | null> {
+ const versionstamp = await core.opAsync(
"op_kv_atomic_write",
this.#rid,
this.#checks,
this.#mutations,
[], // TODO(@losfair): enqueue
);
- return result;
+ if (versionstamp === null) return null;
+ return { versionstamp };
}
then() {