Git Product home page Git Product logo

db's Introduction

db.json

Simple JSON Database. Easy to Use and Very Simple

Installation

To install the node-module

npm install db.simple

Code:

let DB = new require('db.simple')
let db = DB.Database()

Methods

  • .get(name)
  • .set(name, data)
  • .delete(name)
  • .push(name, data)
  • .add(name, number)
  • .subtract(name, number)
  • .all()
  • .startsWith(name)
  • .resetDatabase()

Usage

  • .get(name)
//Get Data with data name //return Data Object if exist 
db.get('epog') //output: {ID:'epog', 'TEST DATA'}
  • .add(name, number)
//Adds a number to a data. //return Data Object 
db.add('epogCount',2) //output: {ID:'epogCount', 3}
  • .subtract(name, number)
// Subtract a number from data
db.subtract('epogCount',2) //output: {ID:'epogCount', 1}
  • .all()
// Returns all data in database
 db.all() //output: [ { ID: 'epogCount', data: 1 }, { ID: 'epog', data: 'TEST DATA' } ]
  • .startsWith(name)
// Returns all data starting with "Specified Name" in database

db.startsWith('Roles_') 
//output:
[
 { ID: 'Roles_1634476131578', data: 102 },
 { ID: 'Roles_1634476131594', data: 232 },
 { ID: 'Roles_1634476131603', data: 10 },
 { ID: 'Roles_1634476131611', data: 3 },
 { ID: 'Roles_1634476131616', data: 5 }
]
  • .delete(name, data)
// Delete data from database
 db.delete('Today')
//output: true
  • .set(name, data)
// Set data to database
 db.set('Today',Date.now())
//output: { ID: 'Today', data: 1634476515562 }
  • .push(name, data)
// push data into Array[]
 db.push('epogArray','asd')
 db.push('epogArray','test')
   //output: 
   [
 {
   ID: 'epogArray',
   data: [ 'asd', 'test' ]
 }
]
  • .resetDatabase()
// Reset Database
 db.resetDatabase()
//output: true

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.