Skip to content

Commit 965e228

Browse files
Document Wrangler Command KV Bulk Get (#21094)
* Document wrangler kv bulk get command * Update src/content/partials/workers/wrangler-commands/kv.mdx Co-authored-by: Thomas Gauvin <[email protected]> * Update src/content/partials/workers/wrangler-commands/kv.mdx Co-authored-by: Thomas Gauvin <[email protected]> * Update src/content/partials/workers/wrangler-commands/kv.mdx Co-authored-by: Thomas Gauvin <[email protected]> * Update src/content/partials/workers/wrangler-commands/kv.mdx Co-authored-by: Thomas Gauvin <[email protected]> --------- Co-authored-by: Thomas Gauvin <[email protected]>
1 parent e5285f0 commit 965e228

File tree

1 file changed

+60
-0
lines changed
  • src/content/partials/workers/wrangler-commands

1 file changed

+60
-0
lines changed

src/content/partials/workers/wrangler-commands/kv.mdx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,66 @@ The `kv ...` commands allow you to manage your Workers KV resources in the Cloud
391391
Since version 3.60.0, Wrangler supports the `kv ...` syntax. If you are using versions below 3.60.0, the command follows the `kv:...` syntax. Learn more about the deprecation of the `kv:...` syntax in the [Wrangler commands](/kv/reference/kv-commands/) for KV page.
392392
:::
393393
394+
<AnchorHeading title="`get`" slug="kv-bulk-get" depth={3} />
395+
396+
Get all keys read from a JSON file within a given namespace.
397+
398+
```txt
399+
wrangler kv bulk get <FILENAME> {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS]
400+
```
401+
402+
:::caution
403+
404+
This command requires `--binding` or `--namespace-id`.
405+
:::
406+
407+
- `FILENAME` <Type text="string" /> <MetaInfo text="required" />
408+
- The JSON file containing an array of keys to read from the namespace.
409+
- `--binding` <Type text="string" />
410+
- The binding name of the namespace, as stored in the Wrangler file, to read from.
411+
- `--namespace-id` <Type text="string" />
412+
- The ID of the namespace to read from.
413+
- `--env` <Type text="string" /> <MetaInfo text="optional" />
414+
- Perform on a specific environment.
415+
- `--preview` <Type text="boolean" /> <MetaInfo text="optional" />
416+
- Interact with a preview namespace instead of production.
417+
- `--local` <Type text="boolean" /> <MetaInfo text="(default: true) optional" />
418+
- Interact with locally persisted data.
419+
- `--remote` <Type text="boolean" /> <MetaInfo text="(default: false) optional" />
420+
- Interact with remote storage.
421+
- `--persist-to` <Type text="string" /> <MetaInfo text="optional" />
422+
- Specify directory for locally persisted data.
423+
424+
<Render file="wrangler-commands/global-flags" product="workers" />
425+
426+
This command takes a JSON file as an argument containing the keys to get.
427+
428+
The following is an example of the JSON input:
429+
430+
```json
431+
["test_key_1", "test_key_2"]
432+
```
433+
434+
The command also accepts keys in the format output from `wrangler kv key list`:
435+
436+
```json
437+
[{ "name": "test_key_1" }, { "name": "test_key_2" }]
438+
```
439+
440+
The following is an example of getting all the keys found in the `keys_to_read.json` file.
441+
442+
```sh
443+
npx wrangler kv bulk get --binding=MY_KV keys_to_read.json
444+
445+
```sh output
446+
{
447+
"test_key_1": "test_key_1-value",
448+
"test_key_2": "test_key_2-value"
449+
}
450+
451+
Success!
452+
```
453+
394454
<AnchorHeading title="`put`" slug="kv-bulk-put" depth={3} />
395455

396456
Write a JSON file containing an array of key-value pairs to the given namespace.

0 commit comments

Comments
 (0)