@gasstack/kv
v0.3.1
Published
Google Apps Script key-value store microframework
Downloads
86
Maintainers
Readme
@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.