#KV multimap / unordered keys search

1 messages · Page 1 of 1 (latest)

buoyant atlas
#

Hello,

I want to do an unordered keys search on deno kv

FoundationDB talk about multimap (https://apple.github.io/foundationdb/multimaps.html ). I don't find it for deno kv.

// deno run --unstable-kv test.ts

const kv = await Deno.openKv();

let res = await kv.set(["users", "alex", "foot"], "alex foot");
console.log(res)
 res = await kv.set(["users", "alex", "basket"], "alex basket");
console.log(res)
 res = await kv.set(["users", "alex", "tennis"], "alex tennis");
console.log(res)

// just want users and basket without alex
// => don't work
const iter = kv.list<string>({ prefix: ["users", "basket"] });
// this work
// const iter = kv.list<string>({ prefix: ["users","alex"] });
const users = [];
for await (const res of iter) users.push(res);
console.log(users[0]); 

 kv.close()
nova widget
#

what do you mean unordered? do you mean arbitrarily ordered?

buoyant atlas
#

in my example, I want to get all keys including ["users", "basket"]or ["basket", "users"], ie I don't care for orders.
kv only authorises strict prefix, here only ["users","alex"] works

In a real usecase, I want to filter on some criteria (country, city, sport...)

nova widget
#

the article you shared is unrelated to the behavior you want

this is something you can achieve by creating your own secondary indices