diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/kv/01_db.ts | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/ext/kv/01_db.ts b/ext/kv/01_db.ts index 05e9a66d8..38dcb4ae0 100644 --- a/ext/kv/01_db.ts +++ b/ext/kv/01_db.ts @@ -48,7 +48,6 @@ class Kv { } async get(key: Deno.KvKey, opts?: { consistency?: Deno.KvConsistencyLevel }) { - key = convertKey(key); const [entries]: [RawKvEntry[]] = await core.opAsync( "op_kv_snapshot_read", this.#rid, @@ -76,7 +75,6 @@ class Kv { keys: Deno.KvKey[], opts?: { consistency?: Deno.KvConsistencyLevel }, ): Promise<Deno.KvEntry<unknown>[]> { - keys = keys.map(convertKey); const ranges: RawKvEntry[][] = await core.opAsync( "op_kv_snapshot_read", this.#rid, @@ -103,7 +101,6 @@ class Kv { } async set(key: Deno.KvKey, value: unknown) { - key = convertKey(key); value = serializeValue(value); const checks: Deno.AtomicCheck[] = []; @@ -123,8 +120,6 @@ class Kv { } async delete(key: Deno.KvKey) { - key = convertKey(key); - const checks: Deno.AtomicCheck[] = []; const mutations = [ [key, "delete", null], @@ -211,14 +206,14 @@ class AtomicOperation { check(...checks: Deno.AtomicCheck[]): this { for (const check of checks) { - this.#checks.push([convertKey(check.key), check.versionstamp]); + this.#checks.push([check.key, check.versionstamp]); } return this; } mutate(...mutations: Deno.KvMutation[]): this { for (const mutation of mutations) { - const key = convertKey(mutation.key); + const key = mutation.key; let type: string; let value: RawValue | null; switch (mutation.type) { @@ -247,12 +242,12 @@ class AtomicOperation { } set(key: Deno.KvKey, value: unknown): this { - this.#mutations.push([convertKey(key), "set", serializeValue(value)]); + this.#mutations.push([key, "set", serializeValue(value)]); return this; } delete(key: Deno.KvKey): this { - this.#mutations.push([convertKey(key), "delete", null]); + this.#mutations.push([key, "delete", null]); return this; } @@ -296,14 +291,6 @@ class KvU64 { } } -function convertKey(key: Deno.KvKey | Deno.KvKeyPart): Deno.KvKey { - if (Array.isArray(key)) { - return key; - } else { - return [key as Deno.KvKeyPart]; - } -} - function deserializeValue(entry: RawKvEntry): Deno.KvEntry<unknown> { const { kind, value } = entry.value; switch (kind) { |