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 insert = await db.insert({ username: "EntenKoeniq" });

if (!insert.error) {
  console.log(`ID: ${insert.id}, created!`);
  console.log(db.findOne(insert.id));
  
  /* ===== UPDATE ===== */
  let update = await db.update(insert.id, "username", "KoeniqEnten");
  
  if (!update.error) console.log("Username updated!");
  else console.error(update.exception);
  /* ===== UPDATE ===== */
} else {
  console.error(insert.exception);
}

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"