KvStore API
The kvStore module of the @codebolt/plugin-sdk.
import plugin from '@codebolt/plugin-sdk';
Quick Reference
| Method | Description |
|---|---|
createInstance | Create a new KV store instance |
delete | Delete a value from the KV store |
deleteInstance | Delete a KV store instance |
deleteNamespace | Delete an entire namespace from the KV store |
get | Get a value from the KV store |
getInstance | Get a KV store instance by ID |
getNamespaces | Get all namespaces in an instance |
getRecordCount | Get record count for an instance or namespace |
listInstances | List all KV store instances |
query | Query the KV store using DSL |
set | Set a value in the KV store |
updateInstance | Update a KV store instance |
Methods
createInstance
plugin.kvStore.createInstance(name: string, description?: string): Promise<KVInstanceResponse>
Create a new KV store instance
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Instance name |
description | string | No | Optional description |
Returns: Promise<KVInstanceResponse>
delete
plugin.kvStore.delete(instanceId: string, namespace: string, key: string): Promise<KVDeleteResponse>
Delete a value from the KV store
| Parameter | Type | Required | Description |
|---|---|---|---|
instanceId | string | Yes | Instance ID |
namespace | string | Yes | Namespace |
key | string | Yes | Key |
Returns: Promise<KVDeleteResponse>
deleteInstance
plugin.kvStore.deleteInstance(instanceId: string): Promise<KVDeleteResponse>
Delete a KV store instance
| Parameter | Type | Required | Description |
|---|---|---|---|
instanceId | string | Yes | Instance ID |
Returns: Promise<KVDeleteResponse>
deleteNamespace
plugin.kvStore.deleteNamespace(instanceId: string, namespace: string): Promise<KVDeleteNamespaceResponse>
Delete an entire namespace from the KV store
| Parameter | Type | Required | Description |
|---|---|---|---|
instanceId | string | Yes | Instance ID |
namespace | string | Yes | Namespace to delete |
Returns: Promise<KVDeleteNamespaceResponse>
get
plugin.kvStore.get(instanceId: string, namespace: string, key: string): Promise<KVGetResponse>
Get a value from the KV store
| Parameter | Type | Required | Description |
|---|---|---|---|
instanceId | string | Yes | Instance ID |
namespace | string | Yes | Namespace |
key | string | Yes | Key |
Returns: Promise<KVGetResponse>
getInstance
plugin.kvStore.getInstance(instanceId: string): Promise<KVInstanceResponse>
Get a KV store instance by ID
| Parameter | Type | Required | Description |
|---|---|---|---|
instanceId | string | Yes | Instance ID |
Returns: Promise<KVInstanceResponse>
getNamespaces
plugin.kvStore.getNamespaces(instanceId: string): Promise<KVNamespacesResponse>
Get all namespaces in an instance
| Parameter | Type | Required | Description |
|---|---|---|---|
instanceId | string | Yes | Instance ID |
Returns: Promise<KVNamespacesResponse>
getRecordCount
plugin.kvStore.getRecordCount(instanceId: string, namespace?: string): Promise<KVRecordCountResponse>
Get record count for an instance or namespace
| Parameter | Type | Required | Description |
|---|---|---|---|
instanceId | string | Yes | Instance ID |
namespace | string | No | Optional namespace filter |
Returns: Promise<KVRecordCountResponse>
listInstances
plugin.kvStore.listInstances(): Promise<KVInstanceListResponse>
List all KV store instances
No parameters.
Returns: Promise<KVInstanceListResponse>
query
plugin.kvStore.query(query: KVQueryDSL): Promise<KVQueryResponse>
Query the KV store using DSL
| Parameter | Type | Required | Description |
|---|---|---|---|
query | KVQueryDSL | Yes | Query DSL object |
Returns: Promise<KVQueryResponse>
set
plugin.kvStore.set(instanceId: string, namespace: string, key: string, value: any, autoCreateInstance: boolean): Promise<KVSetResponse>
Set a value in the KV store
| Parameter | Type | Required | Description |
|---|---|---|---|
instanceId | string | Yes | Instance ID |
namespace | string | Yes | Namespace |
key | string | Yes | Key |
value | any | Yes | Value to store |
autoCreateInstance | boolean | Yes | Auto-create instance if it doesn't exist (default: false) |
Returns: Promise<KVSetResponse>
updateInstance
plugin.kvStore.updateInstance(instanceId: string, updates: UpdateKVInstanceParams): Promise<KVInstanceResponse>
Update a KV store instance
| Parameter | Type | Required | Description |
|---|---|---|---|
instanceId | string | Yes | Instance ID |
updates | UpdateKVInstanceParams | Yes | Update parameters |
Returns: Promise<KVInstanceResponse>