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");

/* ===== INSERT ===== */
let insert = await db.insert({ username: "EntenKoeniq" });
console.log(`ID: ${insert.id}, created!`);

/* ===== FIND ONE ===== */
console.log(db.findOne(insert.id));

/* ===== UPDATE ===== */
await db.update(insert.id, "username", "KoeniqEnten");
console.log("Username updated!");

Quick Usage:Result

{
  "1": {
    "username": "KoeniqEnten"
  }
}

How to use

insert

  db.insert({ short: "cj5f39", clicks: 0 }); // insert an object
  db.insert({ short: "cj5f39", clicks: 0 }, "google.de"); // insert an object with a custom key

exists

  db.exists("google.de"); // return a boolean value

get

  db.get("google.de", "short"); // return the value of "short" => cj5f39

getBy

  db.getBy("short", "cj5f39"); // result => "short": "cj5f39", "clicks": 0
  /*
  "google.de": {
    "short": "cj5f39",
    "clicks": 0
  }
  */

findOne

  db.findOne("google.de"); // result => "short": "cj5f39", "clicks": 0
  /*
  "google.de": {
    "short": "cj5f39",
    "clicks": 0
  }
  */

update

  db.update("google.de", "short", "321"); // replace the value of "short" from "google.de" with "321"