xen.db

A SQLite3 Database. Easy-To-Use For Beginners & Persistent Database.

Usage no npm install needed!

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

README

Xen.db

downloadsBadge versionBadge docs

Xen.db is an open-sourced SQLite3 Database designed to be easy-to-use and beginner friendly. This Database access and store various of data persistently via BetterSQLite3.

Features

  • Powerful - Supports Non-Xen.db Method.
  • Customizable - More Utility Method.
  • Family-Friendly - Simple & Easy-To-Use For Beginners.
  • 100% Based - Key Value Based.
  • Persistent Database - Value Will Not Lost When On Retstarting Session.
  • Free-To-Use - Not Needed To Set Up A SQL Database Server! All Data Is Stored Locally In The Same Project.
  • Custom Database File - Xen.db Allow Users To Create Custom Database File And Its Path!

Example (Default)

Coding A Sandbox (Demo)


const { Database } = require("xen.db");
const db = new Database(); 

// Setting an object in the database:
db.set('userInfo', { difficulty: 'Easy' });
// -> { difficulty: 'Easy' }
 
// Pushing an element to an array (that doesn't exist yet) in an object:
db.push('userInfo.items', 'Sword');
// -> { difficulty: 'Easy', items: ['Sword'] }
 
// Adding to a number (that doesn't exist yet) in an object:
db.add('userInfo.balance', 500);
// -> { difficulty: 'Easy', items: ['Sword'], balance: 500 }
 
// Repeating previous examples:
db.push('userInfo.items', 'Watch');
// -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 500 }
db.add('userInfo.balance', 500);
// -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 1000 }
 
// Fetching individual properties
db.get('userInfo.balance'); // -> 1000
db.get('userInfo.items'); // ['Sword', 'Watch']

Example (Custom)


const { Database } = require("xen.db");
const db = new Database("Database/xen.db", { path: "Database", table: "JSON"});
// Creates a Database File called "xen.db" inside a "Database" folder instead of "json.sqlite"

// Setting an object in the database:
db.set('userInfo', { difficulty: 'Easy' });
// -> { difficulty: 'Easy' }
 
// Pushing an element to an array (that doesn't exist yet) in an object:
db.push('userInfo.items', 'Sword');
// -> { difficulty: 'Easy', items: ['Sword'] }
 
// Adding to a number (that doesn't exist yet) in an object:
db.add('userInfo.balance', 500);
// -> { difficulty: 'Easy', items: ['Sword'], balance: 500 }
 
// Repeating previous examples:
db.push('userInfo.items', 'Watch');
// -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 500 }
db.add('userInfo.balance', 500);
// -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 1000 }
 
// Fetching individual properties
db.get('userInfo.balance'); // -> 1000
db.get('userInfo.items'); // ['Sword', 'Watch']


Creating A Table


// Creates New Table
const table = db.createTable("MyTable");

db.set("Inv", "Sword");
table.set("Inv", "Diamond");

db.get("Inv");
// -> Sword

table.get("Inv");
// -> Diamond


List All Tables


const tables = db.tables();

console.log(tables);


Why Xen.db?

  • Lightweight
  • Consistent
  • Easy-To-Use
  • Customizable
  • Key & Value Based
  • Persistent Database

We've Over 2,000+ Downloads On NPM!

Check Out Our GitHub For Contributions!


Installation

If You Have Trouble Installing Xen.db. Please Follow This Troubleshooting Guide.

Windows Platform
  1. Open: Any Terminal (Eg. PowerShell, Command Prompt)
  2. Run: npm i xen.db
  • If you want to be more updated, you can install the dev version instead: npm i NotMarx/xen.db#dev

Note: Windows Users Might Need To Do The Following Additional Steps.

Mac Platform
  1. Install: XCode
  2. Run: npm i -g node-gyp In Your Console Or Terminal
  3. Run: node-gyp --python /path/to/python2.7
  4. Finally, Run: npm i xen.db

Documentation