KeyValueStorage
A durable key-value store, which an environment declaring tiers: 'session+db' receives as ctx.storage.db.
@internote/canvas-sdkimport { KeyValueStorage } from '@internote/canvas-sdk';Every operation is asynchronous, since a host backs it with a request. The host hands one store to the whole document, so an environment prefixes its keys with something of its own, such as its scene and environment ids, or wraps the store with prefixedKeyValueStorage. An environment declaring the session tier alone receives noopKeyValueStorage, so code that writes to db can be written unconditionally.
#Fields
deleteRemoves a key and its value.
Promise<void>getResolves to the value stored under a key, or
null when there is none.Promise<T | null>setStores a value under a key, replacing any before it.
Promise<void>#Example
const db = prefixedKeyValueStorage(ctx.storage.db, `${ctx.identity.sceneId}:${ctx.identity.environmentId}:`);
await db.set('answers', answers);Declared in packages/canvas-sdk/src/storage/interaction.ts:71.