A simple and lightweight JSON file database
npm i @liting-yes/jsondb
const JsonDB = require('@liting-yes/jsondb')
/**
*
* @param {string} pathDB the absolute path of the database
*/
const db = new JsonDB(pathDB)
/**
*
* @param {string} filePath the relative path of the new database file to the database
* @param {any | undefined} data database file initialization data, default data is {}
*/
db.create(filePath, data)
/**
*
* @param {string} filePath the relative path of the database file witch will be deleted to database
*/
db.delete(filePath)
/**
*
* @param {any} data updated data
* @param {array | undefined} nestedKey where the data is updated
* @param {string | undefined} filePath the relative path of the updated data file to the database
*/
db.update(data, nestedKey, filePath)
/**
*
* @param {array | undefined} nestedKey where to query data
* @param {string | undefined} filePath the relative path from the database file for data query to the database
* @returns queried data
*/
db.query(nestedKey, filePath)
/**
*
* @param {array | undefined} nestedKey where to query the data keys
* @param {string | undefined} filePath the relative path from the database file for keys query to the database
* @returns queryed keys array
*/
db.queryKeys(nestedKey, filePath)
db.pathDB
: the database absolute pathdb.currentFilePath
: the absolute path of the current database filedb.relativePath
: the relative path of the current database file to the database (support setter)