6.0.0 • Published 1 year ago
yarrak.db v6.0.0
INSTALLATION
npm install yarrak.db
// or
yarn add yarrak.db
HOW TO USE MODULE
const {DataBase} = require('yarrak.db');
const db = new DataBase(
'database',
{
backUp: {
active: true,
timeInterval: 1, // minute
}
}
);
METHODS
get, set, has, push, removeArray, getAll, delete, deleteAll, add, subtract, type
HOW TO USE METHODS
{
"test": "test",
"obj": {
"test": "test1"
},
"array": [
"test",
"test2",
"test3"
],
"count": 12,
"active": false
}
get Method
db.get('test'); // Output: 'test'
// or
db.get('obj.test'); // Output: 'test1'
set Method
db.set('name', 'Yusuf'); // Output: 'Yusuf'
// or
db.set('user.name', 'Yusuf'); // Output: {name: 'Yusuf'}
has Method
db.has('asd'); // Output: false
// or
db.has('test'); // Output: true
push Method
db.push('arr', 'test'); // Output: {arr: ['test']}
// or
db.push('db.numbers', [1, 2, 3]); // Output: {db: {numbers: [1, 2, 3]}}
// or
db.push('arr', {name: 'Yusuf'}); // Output: {arr: [{name: Yusuf}]}
removeArray Method
db.removeArray('array', 'test2'); // Output: {array: ['test', 'test3']}
getAll Method
db.getAll(); // Output: Returns all data.
deleteAll Method
db.deleteAll(); // Output: {}
delete Method
db.delete('obj', 'test'); // Output: {obj: {}}
// or
db.delete('test'); // Deleted
add Method
db.add('count', 18); // Output: 30
// or
db.add('newCount', 12); // Output: 12
subtract Method
db.subtract('count', 2); // Output: 10
type Method
db.type('count'); // Output: number
// or
db.type('array'); // Output: array
// or
db.type('test'); // Output: string
// or
db.type('obj'); // Output: object
// or
db.type('active'); // Output: boolean
NOTE
- Important updates for this package coming soon.