1.0.5 • Published 1 year ago
jsonbase-handler v1.0.5
Simple JSON Database
Make a JSON-file-database and interact with it.
Why JSON File?
If you want to create a database, you can make it in your own computer, so with this method only YOU can read/edit the database.
Simple Usage
const jsonbase_handler = require('jsonbase-handler') // Import jsonbase-handler
const Database = new jsonbase_handler('./test.json') // Create new database
Database.reset() // Reset the database and start from scratch
Database.set('test', ['a', 'b', 'c']) // Set variable 'test' to ['a', 'b', 'c']
Database.get('test', console.log) // Get the value of variable 'test' AND console log it
Database.set('test1', 'something') // Set variable 'test1' to 'something'
Database.delete('test1') // Delete variable 'test1' from the database
Database.getData(console.log) // Get the JSON data from the database AND console log it
Methods
get (variable: String) | Returns a variable from the database |
set (variable: String, value: any) | Sets a variable to the value specified in the database |
delete (variable: String) | Deletes a variable from the database |
reset () | Resets the database. |
getData (callback) | Gets all the data from the database. |