diff --git a/src/docs/src/KV/list.md b/src/docs/src/KV/list.md index 0f66240cfa..03b950b90e 100755 --- a/src/docs/src/KV/list.md +++ b/src/docs/src/KV/list.md @@ -86,22 +86,49 @@ If the user has no keys, the array will be empty. Paginate results with a cursor -```html +```html;kv-list-pagination + + ``` Sort keys lexicographically diff --git a/src/docs/src/examples.js b/src/docs/src/examples.js index b6627d3a31..d84a493ed0 100644 --- a/src/docs/src/examples.js +++ b/src/docs/src/examples.js @@ -407,6 +407,12 @@ const examples = [ slug: 'kv-list', source: '/playground/examples/kv-list.html', }, + { + title: 'List (Pagination)', + description: 'Paginate key-value results with a cursor and limit using puter.kv.list(). Run and modify this example in the playground.', + slug: 'kv-list-pagination', + source: '/playground/examples/kv-list-pagination.html', + }, { title: 'List (Sorted)', description: 'See how keys are returned in lexicographic order with puter.kv.list(). Run and modify this example in the playground.', diff --git a/src/docs/src/playground/examples/kv-list-pagination.html b/src/docs/src/playground/examples/kv-list-pagination.html new file mode 100644 index 0000000000..30aa14c712 --- /dev/null +++ b/src/docs/src/playground/examples/kv-list-pagination.html @@ -0,0 +1,41 @@ + + + + + + diff --git a/src/docs/src/playground/examples/kv-list.html b/src/docs/src/playground/examples/kv-list.html index 7c2a8fa9e7..d2fc8dd7e4 100755 --- a/src/docs/src/playground/examples/kv-list.html +++ b/src/docs/src/playground/examples/kv-list.html @@ -7,19 +7,19 @@ await puter.kv.set('name', 'Puter Smith'); await puter.kv.set('age', 21); await puter.kv.set('isCool', true); - document.write("Key-value pairs created/updated

"); + puter.print("Key-value pairs created/updated

"); // (2) Retrieve all keys const keys = await puter.kv.list(); - document.write(`Keys are: ${keys}

`); + puter.print(`Keys are: ${keys}

`); // (3) Retrieve all keys and values const key_vals = await puter.kv.list(true); - document.write(`Keys and values are: ${(key_vals).map((key_val) => key_val.key + ' => ' + key_val.value)}

`); + puter.print(`Keys and values are: ${(key_vals).map((key_val) => key_val.key + ' => ' + key_val.value)}

`); // (4) Match keys with a pattern const keys_matching_pattern = await puter.kv.list('is*'); - document.write(`Keys matching pattern are: ${keys_matching_pattern}
`); + puter.print(`Keys matching pattern are: ${keys_matching_pattern}
`); // (5) Delete all keys (cleanup) await puter.kv.del('name'); @@ -27,4 +27,5 @@ await puter.kv.del('isCool'); })(); - \ No newline at end of file + +