myjsondb
v1.4.0
Published
A simple database with cool stuff
Downloads
3
Readme
#MyJSON A simple database with cool stuff
Install the package
$ npm install myjsondb --save
The data will look something like that
/root of your project
|
+-- ... Your code base
data(the databse root director # Fully customizable)
|
+-- Subdb(ponies)
|
+-- Table(rainbow_dash # Via a JSON format)
|
+-- (Data)
This database is design not to overwrite stuff
###Init the database
db.init({
path: "./data/db"
})
.then( () => {
console.log(`Database init successfully :P`);
})
.catch(error => {
console.error(error)
})
###Create subdb
db.createSubdb("mySubdbName")
.then( dbName => {
console.log(`My awesome ${dbName} was created :P`);
})
.catch(error => {
console.error(error)
})
###Create table
db.createTable("myTable")
.then( tableName => {
console.log(`My awesome ${tableName} was created :P`);
})
.catch(error => {
console.error(error)
})
###Edit data
db.edit("mySubdbName","myTable", {
"newData": "Yeap"
})
.then( () => {
console.log(`My data is been updated :P`);
})
.catch(error => {
console.error(error)
})
###Get data
db.get("mySubdbName","myTable")
.then( data => {
console.log(data);
})
.catch(error => {
console.error(error)
})
###Pushing new data The value can be a JSON object
db.push("mySubdbName","myTable","keyName","value")
.then( data => {
console.log(data);
})
.catch(error => {
console.error(error)
})
###Remove subdb
db.removeSubdb("mySubdbName")
.then( dbName => {
console.log(dbName);
})
.catch(error => {
console.error(error)
})
###Remove table
db.removeTable("mySubdbName","myTableName")
.then( tableName => {
console.log(tableName);
})
.catch(error => {
console.error(error)
})