2.0.0 • Published 5 years ago

jebase v2.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

Jebase - An easy way to store settings or small databases

Build Status npm npm license

First things - first

npm i jebase

Initialization

const { Jebase } = require('jebase')
const db = new Jebase("somewhweretostore.json", {
	accounts: [],
	something: true
})

What does this code do?

  1. Includes Jebase
  2. Loads the database from somewheretostore.json, or if the file does not exist, creates it with these contents:
{
	"accounts": [],
	"something": true
}
  1. 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.

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();!

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

2.0.0

5 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

7 years ago