DamienD
Denoβ€’15mo agoβ€’
9 replies
Damien

How do I get all entries out of Deno.kv

Apologies if this is covered somewhere, I have tried searching through the history.

I have the following data (see pic)

I want to get all "subscribers" so that I can list them out but I seem to be coming up short with what I am trying which is below

const kv = await Deno.openKv();
const subscribers: Subscriber[] = [];

const entries = kv.list<{ email: string; timestamp: string }>({
  prefix: ["subscribers"],
});

for await (const entry of entries) {
  console.log("Entry:", entry); // Debug log
  if (entry.value) {
    subscribers.push({
      email: entry.value.email,
      timestamp: entry.value.timestamp,
    });
  }
}
kv.close();


The only thing I can think of is that my keys are actually ["subscribers","uuid" but I do not know how to get around that!

Thanks in advance for any guidance / pointers on the above! Really enjoying using Deno + Fresh!
image.png
Was this page helpful?