This is a playground
to test code. It runs a full Node.js
environment and already has all of npm
’s 400,000 packages pre-installed, including jebase
with all npm
packages installed. Try it out:
require()
any package directly from npmawait
any promise instead of using callbacks (example)This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
npm i jebase
const { Jebase } = require('jebase')
const db = new Jebase("somewhweretostore.json", {
accounts: [],
something: true
})
somewheretostore.json
, or if the file does not exist, creates it with these contents:{
"accounts": [],
"something": true
}
When you load a database, it is stored inside db.data
object, so you can manipulate it, like it’s a regular JavaScript object.
db.data.accounts.push("george@bygeorgenet.me")
if (db.data.something) {
console.log("Something is enabled")
}
If you have changed something in the database and want to save it, just call db.write();
!
new Jebase(file, defaults)
Returns db
Loads a database file
db.data
Returns object
DB contents
db.write()
Returns void Writes JSON data to disk