D
Deno

help

What is the best way to count values with Deno.Kv?

SÓscar5/15/2023
I want to show the total values in the database. It seems that the only way is with kv.list() and then iterate the values. Probably this is not very performant if I only want to count the results. I'd like to have something like this:
const count = await kv.count(["users"]);

console.log(`There are ${count} users in the database`);
const count = await kv.count(["users"]);

console.log(`There are ${count} users in the database`);
Iiuioiua5/15/2023
GitHub
suggestion: Deno.Kv.count() · Issue #18965 · denoland/deno
This would be useful for cases where one would like to know how many entries exist for a given prefix without processing/storing any of the actual data. Example: const count = await kv.count({ pref...
SÓscar5/15/2023
Oh, I didn't see that. Thanks!

Looking for more? Join the community!