Skip to content

The KV Store provides atomic array operations for appending, removing, and popping values without read-modify-write races. All three endpoints support optional JSON paths for targeting nested arrays, and each operates on a value stored under a key in a SQLite-backed KV table.


Append a value to an array. If the key does not exist, it is created as a new array containing the appended value. When path is supplied, the value is appended to the nested array at that JSON path.

NameInTypeRequiredDescription
keypathstringYesKey name
dbquerystringYesDatabase file path
tablequerystringNoCustom table name (default: "kv_store")
pathquerystringNoJSON path to nested array
historyquerybooleanNoEnable history tracking (default: true)

This endpoint accepts a JSON body containing the value to append.

{
"user": "alice",
"action": "login",
"timestamp": 1700000000
}
{
"key": "events",
"path": null,
"array": [
{ "user": "alice", "action": "login", "timestamp": 1700000000 },
{ "user": "bob", "action": "view", "timestamp": 1700000123 }
],
"length": 2
}
await client.sqlite.kvStore.push({
key: "events",
db: "app.db",
data: {
user: "alice",
action: "login",
timestamp: 1700000000
}
});

Pop the last element from an array. When path is supplied, the last element of the nested array at that JSON path is removed and returned. The remaining array is persisted atomically.

NameInTypeRequiredDescription
keypathstringYesKey name
dbquerystringYesDatabase file path
tablequerystringNoCustom table name (default: "kv_store")
pathquerystringNoJSON path to nested array
historyquerybooleanNoEnable history tracking (default: true)

This endpoint takes no request body.

{
"key": "queue",
"path": null,
"popped": { "id": 42, "payload": "process_me" },
"array": [
{ "id": 41, "payload": "older" }
],
"length": 1
}
const result = await client.sqlite.kvStore.pop({
key: "queue",
db: "app.db"
});
// result.popped — the removed element
// result.array — remaining elements

Remove an element from an array. When index is supplied, the element at that position is removed. Otherwise, the request body value is matched against array elements and the first match is removed. Optional path targets a nested array.

NameInTypeRequiredDescription
keypathstringYesKey name
dbquerystringYesDatabase file path
tablequerystringNoCustom table name (default: "kv_store")
pathquerystringNoJSON path to nested array
indexqueryintegerNoArray index to remove
historyquerybooleanNoEnable history tracking (default: true)

When removing by value, the request body carries the value to match and remove.

{
"id": 42,
"payload": "process_me"
}
{
"key": "queue",
"path": null,
"removed": { "id": 42, "payload": "process_me" },
"array": [
{ "id": 41, "payload": "older" },
{ "id": 40, "payload": "oldest" }
],
"length": 2
}
// Remove by value
await client.sqlite.kvStore.removeElement({
key: "queue",
db: "app.db",
data: { id: 42, payload: "process_me" }
});
// Remove by index
await client.sqlite.kvStore.removeElement({
key: "queue",
db: "app.db",
index: 0
});
// Remove from a nested array
await client.sqlite.kvStore.removeElement({
key: "config",
db: "app.db",
path: "$.allowlist",
data: "10.0.0.5"
});