From 3fbb31c3c1f85011db9cc616dab0ef113342d7dd Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Thu, 27 Apr 2023 16:59:02 +0200 Subject: feat(kv): return ok bool from atomic commit (#18873) --- ext/kv/01_db.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ext/kv') diff --git a/ext/kv/01_db.ts b/ext/kv/01_db.ts index da29a0952..0dd6ba83a 100644 --- a/ext/kv/01_db.ts +++ b/ext/kv/01_db.ts @@ -116,7 +116,7 @@ class Kv { [], ); if (versionstamp === null) throw new TypeError("Failed to set value"); - return { versionstamp }; + return { ok: true, versionstamp }; } async delete(key: Deno.KvKey) { @@ -266,7 +266,7 @@ class AtomicOperation { return this; } - async commit(): Promise { + async commit(): Promise { const versionstamp = await core.opAsync( "op_kv_atomic_write", this.#rid, @@ -274,8 +274,8 @@ class AtomicOperation { this.#mutations, [], // TODO(@losfair): enqueue ); - if (versionstamp === null) return null; - return { versionstamp }; + if (versionstamp === null) return { ok: false }; + return { ok: true, versionstamp }; } then() { -- cgit v1.2.3