diff --git a/src/content/partials/workers/wrangler-commands/kv.mdx b/src/content/partials/workers/wrangler-commands/kv.mdx index 1c98e5307931c9f..4703886ad844648 100644 --- a/src/content/partials/workers/wrangler-commands/kv.mdx +++ b/src/content/partials/workers/wrangler-commands/kv.mdx @@ -391,6 +391,66 @@ 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. ::: + + +Get all keys read from a JSON file within a given namespace. + +```txt +wrangler kv bulk get {--binding=|--namespace-id=} [OPTIONS] +``` + +:::caution + +This command requires `--binding` or `--namespace-id`. +::: + +- `FILENAME` + - The JSON file containing an array of keys to read from the namespace. +- `--binding` + - The binding name of the namespace, as stored in the Wrangler file, to read from. +- `--namespace-id` + - The ID of the namespace to read from. +- `--env` + - Perform on a specific environment. +- `--preview` + - Interact with a preview namespace instead of production. +- `--local` + - Interact with locally persisted data. +- `--remote` + - Interact with remote storage. +- `--persist-to` + - Specify directory for locally persisted data. + + + +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 `keys_to_read.json` file. + +```sh +npx wrangler kv bulk get --binding=MY_KV keys_to_read.json + +```sh output +{ + "test_key_1": "test_key_1-value", + "test_key_2": "test_key_2-value" +} + +Success! +``` + Write a JSON file containing an array of key-value pairs to the given namespace.