Skip to content

The KV Store atomic array operations let you manipulate JSON array values stored in the KV store without race conditions. Use these endpoints to append elements, remove elements by index or value, or pop the last element from an array. All operations support JSON paths for targeting nested arrays inside a stored object, and optionally write to history for audit and rollback workflows.

Append a value to an array stored at key. If the key holds an object, use the path parameter to target a nested array.

NameInTypeRequiredDescription
keypathstringYesKey name
dbquerystringYesDatabase file path
tablequerystringNoCustom table name. Default: kv_store
pathquerystringNoJSON path to nested array
historyquerybooleanNoEnable history tracking. Default: true

A value to append to the array.

{
"event": "user_signup",
"userId": "u_8f2a1b",
"timestamp": "2026-01-15T10:30:00Z"
}

Value appended successfully.

{
"success": true,
"key": "events",
"newLength": 42
}
const result = await client.sqlite.kvStore.push({
key: 'events',
db: '/hoody/databases/app.db',
data: {
event: 'user_signup',
userId: 'u_8f2a1b',
timestamp: '2026-01-15T10:30:00Z'
}
});

Pop the last element from an array stored at key. If the key holds an object, use the path parameter to target a nested array.

NameInTypeRequiredDescription
keypathstringYesKey name
dbquerystringYesDatabase file path
tablequerystringNoCustom table name. Default: kv_store
pathquerystringNoJSON path to nested array
historyquerybooleanNoEnable history tracking. Default: true

Value popped successfully.

{
"key": "events",
"value": {
"event": "user_signup",
"userId": "u_8f2a1b",
"timestamp": "2026-01-15T10:30:00Z"
},
"newLength": 41
}
const result = await client.sqlite.kvStore.pop({
key: 'events',
db: '/hoody/databases/app.db'
});

Remove an element from an array stored at key. Use the index query parameter to remove by position, or pass a value in the request body to remove the first matching element. Supports JSON paths for nested arrays.

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

The value to match and remove. Required when removing by value (i.e. when index is not provided).

{
"event": "user_signup",
"userId": "u_8f2a1b"
}

Element removed successfully.

{
"success": true,
"key": "events",
"removedIndex": 3,
"newLength": 40
}
// Remove by index
const byIndex = await client.sqlite.kvStore.removeElement({
key: 'events',
db: '/hoody/databases/app.db',
index: 3
});
// Remove by matching value
const byValue = await client.sqlite.kvStore.removeElement({
key: 'events',
db: '/hoody/databases/app.db',
data: { event: 'user_signup', userId: 'u_8f2a1b' }
});