mfrancis107
mfrancis1072mo ago

KV watch prefix?

Is there a way to watch a prefix. I would like to be able to watch for any record added to a specific key prefix.
export async function logData(jsonObject: Object) {
const timestamp = Date.now();
const id = nanoid();
try {
console.log("set", timestamp, id);
await kv.set(["dev-logs", timestamp, id], jsonObject);
console.log("done set");
} catch (error) {
console.error(error);
}
}
export async function logData(jsonObject: Object) {
const timestamp = Date.now();
const id = nanoid();
try {
console.log("set", timestamp, id);
await kv.set(["dev-logs", timestamp, id], jsonObject);
console.log("done set");
} catch (error) {
console.error(error);
}
}
I want to be able to
const newLogs = kv.watch([["dev-logs]])
const newLogs = kv.watch([["dev-logs]])
And now I have an iterator that I can watch any new logs added.
0 Replies
No replies yetBe the first to reply to this messageJoin