Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions src/content/partials/workers/wrangler-commands/kv.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,67 @@ The `kv ...` commands allow you to manage your Workers KV resources in the Cloud
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.
:::

<AnchorHeading title="`get`" slug="kv-bulk-get" depth={3} />

Get all keys read from a JSON file within a given namespace.

```txt
wrangler kv bulk get <FILENAME> {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS]
```

:::caution

This command requires `--binding` or `--namespace-id`.
:::

- `FILENAME` <Type text="string" /> <MetaInfo text="required" />
- The JSON file containing an array of keys to delete from the namespace.
- `--binding` <Type text="string" />
- The binding name of the namespace, as stored in the Wrangler file, to delete from.
- `--namespace-id` <Type text="string" />
- The ID of the namespace to delete from.
- `--env` <Type text="string" /> <MetaInfo text="optional" />
- Perform on a specific environment.
- `--preview` <Type text="boolean" /> <MetaInfo text="optional" />
- Interact with a preview namespace instead of production.
- `--local` <Type text="boolean" /> <MetaInfo text="(default: true) optional" />
- Interact with locally persisted data.
- `--remote` <Type text="boolean" /> <MetaInfo text="(default: false) optional" />
- Interact with remote storage.
- `--persist-to` <Type text="string" /> <MetaInfo text="optional" />
- Specify directory for locally persisted data.

<Render file="wrangler-commands/global-flags" product="workers" />

This command takes a JSON file as an argument containing the keys to get.

The following is an example of the JSON input:

```json
["test_key_1", "test_key_2"]
```

The command also accepts keys in the format output from `wrangler kv key list`:

```json
[{ "name": "test_key_1" }, { "name": "test_key_2" }]
```

The following is an example of getting all the keys found in the `allthethingsdelete.json` file.

```sh
npx wrangler kv bulk get --binding=MY_KV allthethingsdelete.json
```

```sh output
{
"test_key_1": "test_key_1-value",
"test_key_2": "test_key_2-value"
}

Success!
```

<AnchorHeading title="`put`" slug="kv-bulk-put" depth={3} />

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