DenoDDeno
Powered by
_pear_
Denoβ€’3y agoβ€’
5 replies
_pear

KV list is returning an empty iterator, but data is there and gettable via get

Hello. To simplify things, I am setting a key of
["accounts", account.name]
["accounts", account.name]
but when I try to get the accounts with
kv.list({ prefix: ["accounts"] })
kv.list({ prefix: ["accounts"] })
, I always get an empty iterator back. I am able to see the record exist when using
kv.get()
kv.get()
.

Here are the relevant snippets; what am I doing wrong, or is this a bug?:

const Db = await Deno.openKv();
//...
await Db.set(["accounts", account.username], account);

//...
const iter = Db.list({ prefix: ["accounts"] }); // why is this always empty?
    for await (const row of iter) {
  console.log(row);
    }
const Db = await Deno.openKv();
//...
await Db.set(["accounts", account.username], account);

//...
const iter = Db.list({ prefix: ["accounts"] }); // why is this always empty?
    for await (const row of iter) {
  console.log(row);
    }
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

get length for KV list via prefix?
nocksockNnocksock / help
3y ago
Is there a way to specify a range and list from KV?
octo3.Oocto3. / help
2y ago
Deno KV equivalent of 'returning'
somethingelse~Ssomethingelse~ / help
3y ago
Is there anyone using kv with pentagon ORM and Zod ?
LikoneLLikone / help
3y ago