diff --git a/cli/tests/unit/kv_test.ts b/cli/tests/unit/kv_test.ts index c50e52c520..6ca9f2afc7 100644 --- a/cli/tests/unit/kv_test.ts +++ b/cli/tests/unit/kv_test.ts @@ -8,25 +8,25 @@ import { } from "./test_util.ts"; Deno.test({ - name: "openKv :memory: no permissions", + name: "kv :memory: no permissions", permissions: {}, async fn() { - const db = await Deno.openKv(":memory:"); + const db = await Deno.kv(":memory:"); await db.close(); }, }); Deno.test({ - name: "openKv invalid filenames", + name: "kv invalid filenames", permissions: {}, async fn() { await assertRejects( - async () => await Deno.openKv(""), + async () => await Deno.kv(""), TypeError, "Filename cannot be empty", ); await assertRejects( - async () => await Deno.openKv(":foo"), + async () => await Deno.kv(":foo"), TypeError, "Filename cannot start with ':' unless prefixed with './'", ); @@ -37,9 +37,7 @@ function dbTest(name: string, fn: (db: Deno.Kv) => Promise) { Deno.test({ name, async fn() { - const db: Deno.Kv = await Deno.openKv( - ":memory:", - ); + const db: Deno.Kv = await Deno.kv(":memory:"); try { await fn(db); } finally { diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts index b042ceabe4..0ea1f89bab 100644 --- a/cli/tsc/dts/lib.deno.unstable.d.ts +++ b/cli/tsc/dts/lib.deno.unstable.d.ts @@ -1535,7 +1535,7 @@ declare namespace Deno { * @tags allow-read, allow-write * @category KV */ - export function openKv(path?: string): Promise; + export function kv(path?: string): Promise; /** **UNSTABLE**: New API, yet to be vetted. * @@ -1876,7 +1876,7 @@ declare namespace Deno { * the returned entry will have a `null` value and versionstamp. * * ```ts - * const db = await Deno.openKv(); + * const db = await Deno.kv(); * const result = await db.get(["foo"]); * result.key; // ["foo"] * result.value; // "bar" @@ -1902,7 +1902,7 @@ declare namespace Deno { * entry will have a `null` value and versionstamp. * * ```ts - * const db = await Deno.openKv(); + * const db = await Deno.kv(); * const result = await db.getMany([["foo"], ["baz"]]); * result[0].key; // ["foo"] * result[0].value; // "bar" @@ -1928,7 +1928,7 @@ declare namespace Deno { * exists for the key, it will be overwritten. * * ```ts - * const db = await Deno.openKv(); + * const db = await Deno.kv(); * await db.set(["foo"], "bar"); * ``` */ @@ -1939,7 +1939,7 @@ declare namespace Deno { * for the key, this operation is a no-op. * * ```ts - * const db = await Deno.openKv(); + * const db = await Deno.kv(); * await db.delete(["foo"]); * ``` */ @@ -1971,7 +1971,7 @@ declare namespace Deno { * not `["users", "noa"]` or `["users", "zoe"]`. * * ```ts - * const db = await Deno.openKv(); + * const db = await Deno.kv(); * const entries = db.list({ prefix: ["users"] }); * for await (const entry of entries) { * entry.key; // ["users", "alice"] diff --git a/ext/kv/01_db.ts b/ext/kv/01_db.ts index 571a1b3cd5..4f1f9bc5ad 100644 --- a/ext/kv/01_db.ts +++ b/ext/kv/01_db.ts @@ -14,7 +14,7 @@ const encodeCursor: ( ) => string = (selector, boundaryKey) => ops.op_kv_encode_cursor(selector, boundaryKey); -async function openKv(path: string) { +async function kv(path: string) { const rid = await core.opAsync("op_kv_database_open", path); return new Kv(rid); } @@ -466,4 +466,4 @@ class KvListIterator extends AsyncIterator } } -export { Kv, KvListIterator, KvU64, openKv }; +export { Kv, kv, KvListIterator, KvU64 }; diff --git a/ext/kv/lib.rs b/ext/kv/lib.rs index 49a59af747..b0b629e33e 100644 --- a/ext/kv/lib.rs +++ b/ext/kv/lib.rs @@ -84,9 +84,7 @@ where { let handler = { let state = state.borrow(); - state - .borrow::() - .check_unstable("Deno.openKv"); + state.borrow::().check_unstable("Deno.kv"); state.borrow::>().clone() }; let db = handler.open(state.clone(), path).await?; diff --git a/ext/kv/sqlite.rs b/ext/kv/sqlite.rs index 17634127f6..7c6fc73a6d 100644 --- a/ext/kv/sqlite.rs +++ b/ext/kv/sqlite.rs @@ -128,8 +128,8 @@ impl DatabaseHandler for SqliteDbHandler

{ { let mut state = state.borrow_mut(); let permissions = state.borrow_mut::

(); - permissions.check_read(path, "Deno.openKv")?; - permissions.check_write(path, "Deno.openKv")?; + permissions.check_read(path, "Deno.kv")?; + permissions.check_write(path, "Deno.kv")?; } let flags = OpenFlags::default().difference(OpenFlags::SQLITE_OPEN_URI); rusqlite::Connection::open_with_flags(path, flags)? diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js index 54480c9c72..dda2c89a8e 100644 --- a/runtime/js/90_deno_ns.js +++ b/runtime/js/90_deno_ns.js @@ -170,7 +170,7 @@ const denoNsUnstable = { funlockSync: fs.funlockSync, upgradeHttp: http.upgradeHttp, upgradeHttpRaw: flash.upgradeHttpRaw, - openKv: kv.openKv, + kv: kv.kv, Kv: kv.Kv, KvU64: kv.KvU64, KvListIterator: kv.KvListIterator,