I know, but I still don't know how to get first and last one since [0] and [length-1] don't work
I know, but I still don't know how to get first and last one since [0] and [length-1] don't work

async function getFirstAndLast(KV: KVNamespace) {
let listResult = await KV.list();
const first = listResult.keys[0];
while(!listResult.list_complete) {
listResult = await KV.list({cursor: listResult.cursor});
}
const last = listResult.keys[listResult.keys.length - 1];
return { first, last };
}