Giter Club home page Giter Club logo

xen.db's Introduction

XenDB

Discord CI CodeFactor GitHub Release NPM

XenDB is an open-source asynchronous NodeJS database driver. This library was built for a simple usage to access, store, and update data at any time easily. These data are stored persistently and securely via various of database supported.

Installation

# For SQLite
npm install xen.db better-sqlite3

# For MySQL
npm install xen.db promise-mysql

Please follow the provided troubleshooting guide if you are having issues installing it.

Example

These are the examples used with different database driver. More database driver will be supported in future versions (such as MongoDB)

SQLite

const { SQLiteDriver } = require("xen.db");
// For custom file path, use the 'fileName' option.
// Eg. new SQLiteDriver({ fileName: "path/mydb.sqlite" });
const db = new SQLiteDriver();

db.set("Name", "Hellorein");
// -> { Name: "Hellorein" } <-

db.set("World", { Time: "Day", Money: 15000 });
// -> { World: { Time: "Day", Money: 15000 } } <-

db.get("World");
// -> { World: { Time: "Day", Money: 15000 } } <-

db.push("Cart", ["Weapon A", "Weapon B"]);
// -> { Cart: ["Weapon A", "Weapon B"] } <-

db.add("World.Money", 5000);
// -> { World: { Time: "Day", Money: 20000 } } <-

MySQL

const { MySQLDriver } = require("xen.db");
const db = new MySQLDriver({
  database: "test",
  host: "localhost",
  password: "password",
  user: "root",
});

(async () => {
  // Connect the database to MySQL. This always come first.
  await db.connect();

  await db.set("Name", "Hellorein");
  // -> { Name: "Hellorein" } <-

  await db.set("World", { Time: "Day", Money: 15000 });
  // -> { World: { Time: "Day", Money: 15000 } } <-

  await db.get("World");
  // -> { World: { Time: "Day", Money: 15000 } } <-

  await db.push("Cart", ["Weapon A", "Weapon B"]);
  // -> { Cart: ["Weapon A", "Weapon B"] } <-

  await db.add("World.Money", 5000);
  // -> { World: { Time: "Day", Money: 20000 } } <-
})();

xen.db's People

Contributors

reinacchi avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.