JSPM

@liting-yes/jsondb

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q34571F
  • License MIT

A simple and lightweight JSON file database

Package Exports

  • @liting-yes/jsondb
  • @liting-yes/jsondb/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@liting-yes/jsondb) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

JsonDB

A simple and lightweight JSON file database

Installtion

npm i @liting-yes/jsondb

Hello JsonDB

const JsonDB = require('@liting-yes/jsondb')

Create Database

/**
 * 
 * @param {string} pathDB the absolute path of the database
 */
const db = new JsonDB(pathDB)

Create a jsondb file

/**
 * 
 * @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)

Delete a jsondb file

/**
 * 
 * @param {string} filePath the relative path of the database file witch will be deleted to database
 */
db.delete(filePath)

Update data

/**
 * 
 * @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)

Query data

/**
 * 
 * @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)

Query keys

/**
 * 
 * @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)

Public property

  • db.pathDB: the database absolute path
  • db.currentFilePath: the absolute path of the current database file
  • db.relativePath: the relative path of the current database file to the database (support setter)