Listing more than 1k KV keys

Hello, can this code list more than 1k data that I saved to KV storage at the same time? NOTE:The code currently lists the data without problems, but I wondered if it lists all data when there is more than 1k data
export default {
async fetch(request, env, ctx) {
const keys = new Set();
let cursor = undefined;

async function gatherKeys() {
while (true) {
const result = await env.LOG_IP.list({ cursor });
for (const { name } of result.keys) {
keys.add(name);
}
if (result.list_complete) {
break;
}
cursor = result.cursor;
}
}

await gatherKeys();

const keysArray = Array.from(keys.values());
const keysText = keysArray.join('\n');

return new Response(keysText, {
status: 200,
headers: { 'Content-Type': 'text/plain' },
});
},
};

export default {
async fetch(request, env, ctx) {
const keys = new Set();
let cursor = undefined;

async function gatherKeys() {
while (true) {
const result = await env.LOG_IP.list({ cursor });
for (const { name } of result.keys) {
keys.add(name);
}
if (result.list_complete) {
break;
}
cursor = result.cursor;
}
}

await gatherKeys();

const keysArray = Array.from(keys.values());
const keysText = keysArray.join('\n');

return new Response(keysText, {
status: 200,
headers: { 'Content-Type': 'text/plain' },
});
},
};

2 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
lokiwind
lokiwindOP2y ago
thank you
Want results from more Discord servers?
Add your server