prefixedKeyValueStorage

Returns a view of a key-value store that prefixes every key, so an environment's keys cannot collide with another's.

@internote/canvas-sdkFunction
On this page
import { prefixedKeyValueStorage } from '@internote/canvas-sdk';

The host hands one KeyValueStorage to the whole document. An environment that keeps several values under plain names scopes them once with this, using its own identity as the prefix, rather than composing the prefix at every call.

#Signature

(store: KeyValueStorage, prefix: string): KeyValueStorage

#Parameters

store
The store to scope.
prefix
The text put before every key.

#Example

const db = prefixedKeyValueStorage(ctx.storage.db, `graph:${ctx.identity.sceneId}:${ctx.identity.environmentId}:`);
const elements = await db.get<ReaderElement[]>('elements');

Declared in packages/canvas-sdk/src/storage/interaction.ts:103.

Last updated