Skip to content
Hoody.com

The KV store supports atomic mutations against array-valued keys: append elements to the end, pop the last element, or remove an element by index or value. All three operations accept a JSON path so they can target a nested array inside an object. Use these endpoints when you need a single round-trip to mutate an array without read-modify-write races.

All endpoints require the db query parameter identifying the SQLite database file.

Pop the last element from an array value. Supports JSON paths for nested arrays.

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": "recent_logins",
"value": "2024-05-12T14:30:00Z",
"newLength": 4
}
import { HoodyClient } from 'hoody-sdk';
const client = new HoodyClient({ baseURL: 'https://{projectId}-{containerId}-sqlite-1.{server}.containers.hoody.com', token: process.env.HOODY_TOKEN });
await client.sqlite.kvStore.pop('recent_logins', { db: 'app.db' });

Append a value to an array value. Supports JSON paths for nested arrays.

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

A JSON body is required containing the value to append to the array. The body schema is open (no defined fields), so any JSON object is accepted.

{}

Value appended successfully.

{
"key": "recent_logins",
"index": 4,
"newLength": 5
}
import { HoodyClient } from 'hoody-sdk';
const client = new HoodyClient({ baseURL: 'https://{projectId}-{containerId}-sqlite-1.{server}.containers.hoody.com', token: process.env.HOODY_TOKEN });
await client.sqlite.kvStore.push('recent_logins', {}, { db: 'app.db' });

Remove an element from an array by index or by matching value. Supports JSON paths for nested arrays. Use the index query parameter to target a position, or include the value to match in the request body.

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

A JSON body is required when removing by value, containing the value to match and remove from the array. The body schema is open (no defined fields), so any JSON object is accepted. Omit the body and use the index query parameter instead to remove by position.

{}

Element removed successfully.

{
"key": "active_sessions",
"removed": true,
"index": 2,
"newLength": 3
}
import { HoodyClient } from 'hoody-sdk';
const client = new HoodyClient({ baseURL: 'https://{projectId}-{containerId}-sqlite-1.{server}.containers.hoody.com', token: process.env.HOODY_TOKEN });
await client.sqlite.kvStore.removeElement('active_sessions', {}, { db: 'app.db', index: 2 });