Cheat-Code Sam
Cheat-Code Sam
DDeno
Created by Cheat-Code Sam on 5/25/2024 in #help
Indexing Items by Last Updated Time in Deno KV
It's a little exhaustive, but that's just the nature of working with the kv
13 replies
DDeno
Created by Cheat-Code Sam on 5/25/2024 in #help
Indexing Items by Last Updated Time in Deno KV
And when a thread is updated I could do something like this
const newThreadthread = "modified thread object"
await kv
.atomic()
.set(["thread", id], thread)
.set(["thread", "last_updated", lastUpdated, id], thread)
.delete(["thread", "last_updated", oldLastUpdated, id])
.commit()
const newThreadthread = "modified thread object"
await kv
.atomic()
.set(["thread", id], thread)
.set(["thread", "last_updated", lastUpdated, id], thread)
.delete(["thread", "last_updated", oldLastUpdated, id])
.commit()
13 replies
DDeno
Created by Cheat-Code Sam on 5/25/2024 in #help
Indexing Items by Last Updated Time in Deno KV
const thread = await kv.get<Thread>(["thread", id])
await kv
.atomic()
.delete(["thread", id])
.delete(["thread", "last_updated", thread.value.lastUpdated, id])
.commit()
const thread = await kv.get<Thread>(["thread", id])
await kv
.atomic()
.delete(["thread", id])
.delete(["thread", "last_updated", thread.value.lastUpdated, id])
.commit()
I think this would work
13 replies
DDeno
Created by Cheat-Code Sam on 5/25/2024 in #help
Indexing Items by Last Updated Time in Deno KV
Why so? Wouldn't I query by
kv.list({ prefix: ["threads", "last_updated"] }, { limit: 20 })
kv.list({ prefix: ["threads", "last_updated"] }, { limit: 20 })
Which would return a list of threads sorted by last updated, with a limit of 20.
13 replies
DDeno
Created by Cheat-Code Sam on 5/25/2024 in #help
Indexing Items by Last Updated Time in Deno KV
This actually makes a lot of sense, I never would have thought of that. Thank you!
13 replies