5c36b2f7bcf895b03dfe475daca2391b634e01da
Simplistic JSON database
- Save / load all data from one JSON file
- Automatically saves data after any modifications (create / update / delete)
- Autoincremented ids
Usage
import { Database } from "./database.ts";
import { Table } from "./table.ts";
const database = await Database.load("./data.json", async (emptyDatabase) => {
await emptyDatabase.createTable("foo");
await emptyDatabase.createTable("bar");
await emptyDatabase.createTable("baz");
});
const fooTable = await database.getTable("foo") as Table<{
id: number;
name: string;
}>;
const insertedEntry = await fooTable.insert({ name: "Hello world" });
const updatedEntries = await fooTable.update(
(candidat) => candidat.id === insertedEntry.id,
(entry) => entry.name = "Goodbye",
);
const deletedEntries = await fooTable.delete(() => true);
Description
Releases
1
Initial release
Latest
Languages
TypeScript
100%