Localforage

Introduction

This guide will show you how to use localForage to manage configurations via the Configu interface. Learn about the concept of stores.

Working with the store

SDK installation

Install the browser SDK

// * Using yarn
yarn add @configu/browser
// * Using npm
npm install --save @configu/browser

SDK usage

import { Cfgu, Set, UpsertCommand, EvalCommand, DeleteCommand, LocalForageStore} from "@configu/browser";
import path from "path";

const store = new LocalForageStore({ name: "example" });
const schema = new Cfgu(cfguBlob);
const set = new Set("dev");

// * Example upsert command
await new UpsertCommand({ store, set, schema, configs: [{ key: "foo", value: "bar" }] }).run();

// * Example eval command
const configs = await new EvalCommand({ store, set, schema }).run();

// * Example delete command
await new DeleteCommand({ store, set, schema }).run();

References

To reference a value from this store, use the following reference format:

{{localforage://<databaseName>:<datastoreName>@[set/]<schema>[.key][?key=[key]]}}

Example:

{{localforage://example-db:example-store@example-set/example-schema.foo}}

Limitations

  • There is no CLI support for localForage because it is not relevant for browser stores.