Readme

Val Town Adapter for lowdb

@std/blob is used as a lowdb sync.

See @pomdtr/lowdb_example for example usage.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { blob } from "https://esm.town/v/std/blob?v=10";
import { Low } from "npm:lowdb@7.0.1";
class Blob<Data> {
readonly key: string;
constructor(key: string) {
this.key = key;
}
async read(): Promise<Data> {
const data = await blob.getJSON(this.key);
return data;
}
async write(data: Data) {
await blob.setJSON(this.key, data);
}
}
async function BlobPreset<Data>(key: string, initialData: Data) {
const db = new Low(new Blob<Data>(key), initialData);
await db.read();
return db;
}
export { Blob, BlobPreset };
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.