@gasstack/kv
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

@gasstack/kv

The package is meant to allow the creation and usage of key-value store in Google App Script applications.

Description

The package allows create basic managed (handling serialization and deserialization) KV store using Properties, Spreadsheets, Documents, etc.

Usage

It is possible to create a KV store from a property store:

const kv = createPropertiesStore(PropertiesService.getDocumentProperties());

kv.set("obj", { name: "test", value: 10 });

console.log(kv.get("obj").value);

It is possible to create a KV store from a cache:

const kv = createCacheStore(CacheService.getDocumentCache());

kv.set("obj", { name: "test", value: 10 });

console.log(kv.get("obj").value);

It is possible to create a KV store from a Spreadsheet range:

const kv = createSpreadsheetStore(
  SpreadsheetApp.getActive()
    .getRange("B1:C1")
    .getDataRegion(SpreadsheetApp.Dimension.ROWS)
);

kv.set("obj", { name: "test", value: 10 });

console.log(kv.get("obj").value);

Example

Have a look to the e2e test.

API

API Reference

/@gasstack/kv/

    Package Sidebar

    Install

    npm i @gasstack/kv

    Weekly Downloads

    1

    Version

    0.3.1

    License

    MIT

    Unpacked Size

    7.06 kB

    Total Files

    5

    Last publish

    Collaborators

    • gcanossa