JSPM

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

A database library stores JSON file for Node.js.

Package Exports

  • concisedb
  • concisedb/dist/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 (concisedb) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

concisedb

A database library stores JSON file for Node.js.

Here is what updated every version if you want to know.

API Document

Usage

  1. Install this library

You can also use other package managers like yarn and pnpm instead

npm install concisedb
  1. Example code

This library also supports TypeScript

const ConciseDb = require('concisedb')
const path = require('path')

// The third argument is Options for the class. Access https://docs.lkzstudio.com/concisedb/ if you wanna know what options can change
const db = new ConciseDb(path.join(__dirname, 'db.json'), { test: [] })

db.data.test.push(1) // It will update JSON file automatically by using Proxy
// So for performance, if you need to change the data many times at once
// you can use db.getData() to get a copy of data
// Of course, you can give the class { realtimeUpdate: false } to the third argument
// to prevent the program from updating the JSON file automatically

console.log(db.data) // Output: { test: [ 1 ] }
import ConciseDb from 'concisedb'
import { join } from 'path'

interface Database {
  test: number[]
}

// The third argument is Options for the class. Access https://docs.lkzstudio.com/concisedb/ if you wanna know what options can change
const db = new ConciseDb<Database>(join(__dirname, 'db.json'), { test: [] })

db.data.test.push(1) // It will update JSON file automatically by using Proxy
// So for performance, if you need to change the data many times at once
// you can use db.getData() to get a copy of data
// Of course, you can give the class { realtimeUpdate: false } to the third argument
// to prevent the program from updating the JSON file automatically

console.log(db.data) // Output: { test: [ 1 ] }
  1. Don't worry if you change the type of T

The program will automatically update the content of the JSON file

If the JSON file is exist, the program will compare the content of the JSON file with data you give.

The exist data of the JSON file will take the place of data you give

and the non-exist data of the JSON file will use the default data which you give.