Configuration options for creating KeyValue model instances.

The namespace option allows you to create isolated key-value stores that don't interfere with each other, even when using the same keys. This is essential for organizing different types of data and preventing key collisions.

Example: Default Namespace

// Uses default 'studio' namespace
const store = KeyValue.instance('my-store')
.options({})
.build();

Example: Custom Namespace

// Create isolated stores with custom namespaces
const userStore = KeyValue.instance('user')
.options({ namespace: 'user-data' })
.build();

const appStore = KeyValue.instance('app')
.options({ namespace: 'app-state' })
.build();

// Same key, different namespaces = no collision
await userStore.updateState('id', 'user-123');
await appStore.updateState('id', 'app-456');

Example: Namespace Conventions

// Recommended namespace patterns
const examples: KeyValueOptions[] = [
{ namespace: 'user-preferences' }, // User-specific settings
{ namespace: 'application-state' }, // Global app state
{ namespace: 'feature-flags' }, // Feature toggles
{ namespace: 'session-data' }, // Session-specific data
{ namespace: 'cache-layer' }, // Cached API responses
{ namespace: 'dev-tools' } // Development/debug data
];
interface KeyValueOptions {
    namespace?: string;
}

Properties

Properties

namespace?: string

Namespace for the key-value store to prevent key collisions between different stores.

Defaults to 'studio' if not specified. Choose descriptive namespaces that clearly indicate the purpose of the stored data.

Default

'studio'