rex.db
rex.db - updated version of quick.db with a lot more features.
- Persistent storage w/ no setup (Data doesn't disappear through restarts)
- Beginner Friendly
- Simple Documentation
- Similar to quick.db
- Discord Support
- Multiple tables support
- and more!
Examples
const db = ; // init the databasedb; // Setting an object in the database:db// -> { difficulty: 'Easy' } // Pushing an element to an array (that doesn't exist yet) in an object:db// -> { difficulty: 'Easy', items: ['Sword'] } // Adding to a number (that doesn't exist yet) in an object:db// -> { difficulty: 'Easy', items: ['Sword'], balance: 500 } // Repeating previous examples:db// -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 500 }db// -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 1000 } // Fetching individual propertiesdb // -> 1000db // ['Sword', 'Watch'] // Deleting the tabledb // boolean
Additional Features
Note: Using db.init() is compulsory.
Custom Database Name, Path
const db = ;db; // creates database.sqlite in the given path.
Deleting the table
Default table name is json
.
db;
Math
db.add
ordb.subtract
is not available in this package.
db.math supports add, sub, div, mul and mod. It can be used like this:
db;
Example:
const db = ;db; // adddb; // subdb; // moddb; // muldb; // divdb;
SQL
You can use custom SQL statements in this db.
Example
const db = ;const sql = db; // Set using dblet set = db;console; // fetch using SQL statementlet data = sql;console;
Installation
If you're having troubles installing, please follow this troubleshooting guide.
Linux & Windows
npm i rex.db
Note: Windows users may need to do additional steps listed here.
Mac
- Install: XCode
- Run:
npm i -g node-gyp
in terminal - Run:
node-gyp --python /path/to/python2.7
(skip this step if you didn't install python 3.x) - Run:
npm i rex.db