Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

json-database-db

diegobreeg46ISC1.0.10TypeScript support: included

Methods to store data on format files

json-db, json, database, json database, json-database, local database

readme

Json-Database-db

This library allows you to easily create an local database in JSON format. github: https://github.com/DiegoBreeg/json-db.git

Usage

Install this library:
$ npm i json-database-db

Import or require the library to your code

const { Model } = require('json-database-db')
import { Model } from 'json-database-db'

Use the Model class to instantiate an object capable of manipulating the database
Model class require 2 arguments
-Collection/Database name: string with Collection name.
-schema: an object with key names and the types of their values.

ObjectValidator.validate(dummy: any, rule: any): boolean
const { Model } = require('json-database-db')

const schema = {
    name: { type: String, unique: false },
    LastName: { type: String, unique: false }

}

const Users = new Model('Books', schema)
Users.Save({name: 'Jhoe', LastName: 'Doe'})
Users.FindAll()

schema also accepts Arrays and Objects.

const { Model } = require('json-database-db')

const Users = new Model('Users', {
    name: { type: String },
    age: { type: Number },
    hobbie: { type: [] },
    skills: { type: {} }
})

Users.Save({
    name: 'joe',
    age: 27,
    hobbie: ['programin', 'read books'],
    skills: { smart: 'true' } })