Skip to content

The KV Store basic operations let you read, write, increment, decrement, delete, and check the existence of key-value pairs stored in SQLite. Use these endpoints for counters, configuration values, session data, and any workload that needs simple key-based storage with optional TTL and JSON path support.

Retrieve a value from the KV store. Supports hierarchical keys (using / as a separator), JSON path extraction for nested values, and time-travel queries via a Unix timestamp.

NameInTypeRequiredDescription
keypathstringYesKey name (supports / for hierarchical keys)
dbquerystringYesDatabase file path or directory
tablequerystringNoCustom table name (default: kv_store)
pathquerystringNoJSON path for nested value extraction
at_timestampqueryintegerNoUnix timestamp for time-travel query (selects handleKVAtTimestamp)
rebuildquerybooleanNoRebuild cache (directory mode only)

The response body contains the raw stored value. Metadata is returned in response headers:

  • Content-Type — MIME type of the stored value
  • X-Created-At — Unix timestamp when created
  • X-Updated-At — Unix timestamp when last updated
  • X-Expire-At — Unix timestamp when the value expires (if TTL set)
  • X-KV-Reference — Set to true if the value is a KV store reference
"{\"user\":\"alice\",\"score\":42}"
const value = await client.sqlite.kvStore.get({
key: "users/alice",
db: "/hoody/databases/app.db"
});

Store or update a value in the KV store. Supports TTL (time-to-live), JSON path updates for nested values, and compare-and-swap (CAS) writes via the if_match parameter.

NameInTypeRequiredDescription
keypathstringYesKey name
dbquerystringYesDatabase file path
tablequerystringNoCustom table name (default: kv_store)
pathquerystringNoJSON path for nested value update
ttlqueryintegerNoTime-to-live in seconds
if_matchquerystringNoCurrent value for compare-and-swap
historyquerybooleanNoEnable history tracking (default: true)
create_db_if_missingquerybooleanNoCreate database file if it is missing (default: false)

The raw value to store. Send JSON for structured data or application/octet-stream for binary payloads.

{
"user": "alice",
"score": 42,
"tags": ["admin", "beta"]
}
{
"status": "ok",
"key": "users/alice",
"created": false
}
await client.sqlite.kvStore.set({
key: "users/alice",
db: "/hoody/databases/app.db",
ttl: 3600,
data: { user: "alice", score: 42 }
});

Remove a key-value pair from the store.

NameInTypeRequiredDescription
keypathstringYesKey name
dbquerystringYesDatabase file path or directory
tablequerystringNoCustom table name (default: kv_store)
historyquerybooleanNoEnable history tracking (default: true)
{
"status": "ok",
"key": "users/alice",
"deleted": true
}
await client.sqlite.kvStore.delete({
key: "users/alice",
db: "/hoody/databases/app.db"
});

Check if a key exists in the KV store without retrieving its value. Returns 200 if the key is present, 404 if it is missing or expired.

NameInTypeRequiredDescription
keypathstringYesKey name
dbquerystringYesDatabase file path or directory
tablequerystringNoCustom table name (default: kv_store)
HTTP/1.1 200 OK
const present = await client.sqlite.kvStore.exists({
key: "users/alice",
db: "/hoody/databases/app.db"
});

Atomically increment a numeric value. Supports a custom delta, JSON path targeting for nested numeric values, and optional history tracking. The key must already hold a numeric (or null/initialized) value; non-numeric values result in a 400.

NameInTypeRequiredDescription
keypathstringYesKey name
dbquerystringYesDatabase file path
tablequerystringNoCustom table name (default: kv_store)
deltaqueryintegerNoAmount to increment (default: 1)
pathquerystringNoJSON path to nested numeric value
historyquerybooleanNoEnable history tracking (default: true)
{
"key": "counters/page_views",
"value": 1042,
"previous": 1041
}
const result = await client.sqlite.kvStore.incr({
key: "counters/page_views",
db: "/hoody/databases/app.db",
delta: 1
});

Atomically decrement a numeric value. Supports a custom delta, JSON path targeting for nested numeric values, and optional history tracking.

NameInTypeRequiredDescription
keypathstringYesKey name
dbquerystringYesDatabase file path
tablequerystringNoCustom table name (default: kv_store)
deltaqueryintegerNoAmount to decrement (default: 1)
pathquerystringNoJSON path to nested numeric value
historyquerybooleanNoEnable history tracking (default: true)
{
"key": "counters/inventory",
"value": 97,
"previous": 98
}
const result = await client.sqlite.kvStore.decr({
key: "counters/inventory",
db: "/hoody/databases/app.db",
delta: 1
});