Reference
Nodes
Resources
K/V Store

K/V Store Resource

The Key/Value Store Resource is a batteries-included, minimalist persistence layer for your app.

The store is a fully-managed, linearly scalable key-value storage system running on a distributed database. Keys must be strings, but values can be any JSON content.

Programmatic Access

Programmatic access to the key/value store is available in server-side runtimes, such as the TypeScript Server Resource (opens in a new tab).

Example: TypeScript Server

await kv.set('example-key', { 'example value': 123 })
await kv.get('example-key') // => returns { "example value": 123 }
await kv.delete('example-key')

Properties

Keyspace

Propkeyspace
Typestring
Defaultdefault

The K/V store keyspace to use for all functions on this node. Specifying a keyspace introduces a prefix to all keys.

Actions

Get Key/Value Record

Gets a single record in the key/value store by key.

ParameterTypeDefault
keystringundefined

Set Key/Value Record

Sets a single key/value record specified by key.

ParameterTypeDefault
keystringundefined
valueunknownundefined

List Records

Lists all key/value records.

ParameterTypeDefault
patternstringundefined

List Keys

Lists all keys in the specified range.

ParameterTypeDefault
patternstringundefined

Delete Record

Deletes a single key/value record by key.

ParameterTypeDefault
keystringundefined

Increment Key

Increments a numeric field on a specific key/value record.

ParameterTypeDefault
keystringundefined
amountnumber1

Decrement Key

Decrements a numeric field on a specific key/value record.

ParameterTypeDefault
keystringundefined
amountnumber1