SimpleDB
Simple JSON "database" for Deno.
INFO: If you find a bug or have a feature request, feel free to create an issue or contribute. 🙂
Run
deno run --allow-read --allow-write xxx.ts
Quick Usage
import { SimpleDB } from "https://raw.githubusercontent.com/EntenKoeniq/SimpleDB/master/mod.ts";
const db = new SimpleDB();
await db.connect("dbtest.json");
let result = db.insert({ username: "EntenKoeniq" });
if (!result.error) {
console.log(`ID: ${result.id}, created!`);
if (db.exists(result.id)) console.log(db.findOne(result.id));
}
Quick Usage:Result
{
"1": {
"username": "EntenKoeniq"
}
}
How to use
insert
db.insert({ data: "data" }); // insert an object
db.insert({ data: "data" }, "customKey"); // insert an object with a custom key
exists
db.exists(result.id); // return boolean
get
db.get(result.id, "username"); // return the value of "username"
findOne
db.findOne(result.id); // return all data from id or custom key
update
db.update(result.id, "username", "EntenKoeniq"); // replace "username" from "result.id" with "EntenKoeniq"