Jebase - An easy way to store settings or small databases
First things - first
npm i jebase
Initialization
const Jebase = const db = "somewhweretostore.json" accounts: something: true
What does this code do?
- Includes Jebase
- Loads the database from
somewheretostore.json
, or if the file does not exist, creates it with these contents:
- Done!
Interacting with data
When you load a database, it is stored inside db.data
object, so you can manipulate it, like it’s a regular JavaScript object.
dbdataaccountsif dbdatasomething console
If you have changed something in the database and want to save it, just call db.write();
!
Methods
new Jebase(file, defaults)
Returns db
Loads a database file
- file - relative or absolute path to JSON file
- defaults - what to write to the database if the file does not exist
db.data
Returns object
DB contents
db.write()
Returns void Writes JSON data to disk