introduction
a frontend database management library
install
pnpm add @imshann/database
usage
initialize
import Database from "@imshann/database";
const db = new Database({
name: "minesee",
path: "/path/to/directory",
});
insert
db.table("user").insert({ id: 1, name: "shann" });
then
{
"data": [{ "id": 1, "name": "shann" }],
"primaryKey": "id",
"increment": 2
}
query
db.table("user").queryAll();
db.table("user").where({ id: 1 }).queryOne();
update
db.table("user").update({ id: 1, name: "ping" });
delete
db.table("user").delete(1);
then:
{
"data": [],
"primaryKey": "id",
"increment": 2
}
empty
db.table("user").empty();
then:
{
"data": [],
"primaryKey": "id",
"increment": 1
}