chi.db

Smallest and fastest JSON database for Node, Electron and browser.

Usage no npm install needed!

<script type="module">
  import chiDb from 'https://cdn.skypack.dev/chi.db';
</script>

README

chi.db

Small and fast JSON database for Node and browser.

downloads version

Installation

Warning: chi.db is requires node.js version greater than 12!

npm i chi.db

Or, if you're using yarn

yarn add chi.db

Also, if you want to use chi.db in browser

<script src="https://unpkg.com/chi.db@2.6.0/dist/LocalStorage.min.js"></script>
<script>
  const db = new LocalStorage();
</script> 

Features

  • Fast
  • Lightweight
  • Easy to use
  • Simple
  • Beginner friendly
  • Dot notation
  • Relative path support
  • Browser support
  • MongoDB support

Usage

MongoDB Usage

const { MongoDB } = require("chi.db");
const db = new MongoDB("your mongo connect url", "your schema name");

// To update or set your data;
await db.set("example", "test"); // -> test

// To get your data;
await db.get("example"); // -> test

// To delete your data;
await db.delete("example"); // -> true

// To increase your data;
await db.add("example", 2); // -> 2

// To decrase your data;
await db.subtract("example", 1); // -> 1

// To learn database has the data;
await db.has("example"); // -> true

// To push the data;
await db.push("example", "test"); // -> "test"

// To pull the data;
await db.pull("example", "test"); // -> []

// To get all data;
await db.all();

// To delete all data;
await db.clear();

// To create a collection;
await db.createCollection("collection name");

// To delete collection you've connected;
await db.dropCollection();

// To learn database's uptime;
db.uptime();

// To change your schema name;
db.updateModel("new schema name");

// To create a schema;
db.createSchema("schema name");

JSON Database Usage

const { Database } = require("chi.db");
const db = new Database();
// If you want you specify the file to save the data like; new Database("myDatas");

// To update or set your data;
db.set("example", "test"); // -> test

// To get your data;
db.get("example"); // -> test

// To delete your data;
db.delete("example"); // -> true

// To increase your data;
db.add("example", 2); // -> 2

// To decrase your data;
db.subtract("example", 1); // -> 1

// To learn database has the data;
db.has("example"); // -> true

// To push the data;
db.push("example", "test"); // -> "test"

// To pull the data;
db.pull("example", "test"); // -> []

// To get all data;
db.all();

// To delete all data;
db.clear();

// To get database's ping;
db.ping();