json-database-db
TypeScript icon, indicating that this package has built-in type declarations

1.0.10 • Public • Published

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' } })

Package Sidebar

Install

npm i json-database-db

Weekly Downloads

2

Version

1.0.10

License

ISC

Unpacked Size

25 kB

Total Files

6

Last publish

Collaborators

  • diegobreeg