Skip to content

Latest commit

 

History

History
51 lines (31 loc) · 1.1 KB

README.md

File metadata and controls

51 lines (31 loc) · 1.1 KB

@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