npm install aminnairi/microdatabase
import { InMemoryPersistence, createDatabase } from "../src";
import { randomUUID } from "crypto";
type Database = {
users: {
id: string,
email: string,
username: string
}
}
const { persist, all, add } = await createDatabase<Database>({
persistence: new InMemoryPersistence<Database>({
users: []
})
});
add({
table: "users",
data: {
id: randomUUID(),
email: "[email protected]",
username: "user123"
}
});
const users = all({
table: "users"
});
console.log(users);
await persist();