Open uga-rosa opened 9 months ago
I would at least like a reply as to whether it is a bug or a spec.
IIUC, yes, this is expected behaviour. @igorzi or @losfair, is that right?
Neither the fact that you can't get an exact match key with prefix selector alone, nor the fact that you can get it by adding start, is non-trivial behavior, nor can it be read from the documentation. If this is a specification, then the documentation needs to be improved.
https://deno.land/api@v1.40.2?s=Deno.Kv&unstable=&p=prototype.list
This is a bug. The second case should return the same result as the first.
Version: Deno 1.39.1 (the most recent release)
Summary
The prefix selector of
kv.list()
cannot get an entry for an exact match key, but it can ifstart
is specified. Thestart
is supposed to be for narrowing down, but it is odd behavior that this would increase the number of entries.Test code
const db = await Deno.openKv("./test.sqlite3"); for (const d of data) { await db.set(d.key, d.value); }
console.log("only prefix"); for await (const entry of db.list({ prefix: ["data"] })) { console.log(entry.value); }
console.log("prefix and start"); for await (const entry of db.list({ prefix: ["data"], start: ["data"] })) { console.log(entry.value); }
db.close();