An easy to use package that makes database with JSON.
How to install:
npm install daniel.db
Methods:
create()
const DanielDB = require("daniel.db")
const db = new DanielDB({ name: "main" })
add()
// Increases the current value to the key
db.add('joins', 1)
set()
// Sets the key to value
db.set(`name`, 'daniel')
get()
// Get a value from the key
db.get(`name`)
has()
// Returns if the database has the provided key
db.has(`name`)
delete()
// Deletes a key from the database
db.delete(`name`)
deleteAll()
// Deletes all the keys in the database
db.deleteAll()
// Done!
all()
// Returns an array of objects (ID, data)
db.all()
push()
// Pushes a value to the array
db.push(`name`, 'hello')
reset()
// Resets the key in the database to 0
db.reset(`joins`)
WARNING:
If you're using nodemon
, please use the --ignore
file to ignore all the json files, or else your project will restart every time the database getting updated.
Example:
nodemon fileName.js --ignore *.json
If do you want to run your main file, dont write the [fileName]
in the command.