GithubHelp home page GithubHelp logo

treestang / json.db Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 12 KB

a simple json-based database wrapper

Home Page: https://www.npmjs.com/package/jayson.database

TypeScript 70.64% JavaScript 29.36%
database discord discord-bot discord-js json

json.db's Introduction

jayson.database

a simple and small json-based database wrapper

j(ay)son.database is an lightweight open-sourced package meant to provide an easy way for beginners to get integrated into using databases. it utilizes json files to store data making data easily viewable for all users.

installation

npm i jayson.database

usage

import { JsonDB } from 'jayson-database' 

const db = new JsonDB({
    path: 'test.json'
}) // create a new instance of your database

const run = async () => {
    db.set('abc', 'alphabet') // sets the value of abc to alphabet
    db.set('abcObject', {
        a: 1,
        b: 2,
        c: 3
    }) // sets the value of abcObject to an object with a, b, and c values
    db.set('abcObject.a', 4) // sets the value of abcObject.a to 4

    db.get('abc') // 'alphabet'
    db.get('abcObject') // { a: 4, b: 2, c: 3 }
    db.get('abcObject.a') // 4

    db.delete('abc') // deletes the value of abc
    db.delete('abcObject.a') // deletes the value of abcObject.a
    db.get('abc') // undefined
    db.get('abcObject.a') // undefined

    db.has('abc2') // false
    db.has('abcObject') // true

    db.clear() // clears the database
    db.get('abcObject') // undefined

    db.set('abc', 'alphabet')
    db.set('abcObject', {
        a: 1,
        b: 2,
        c: 3
    })
    db.all() // { abc: 'alphabet', abcObject: { a: 1, b: 2, c: 3 } }

}

run()

json.db's People

Contributors

treestang avatar

Watchers

 avatar

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.