Coder Social home page Coder Social logo

jifdb's Introduction

Jifdb

Jifdb is a synchronous JSON.file-based Database for Node.js applications - a minimal CommonJS module using JSON-file storage and CRUD (Create, Read, Update, Delete) accessors.

Please note(!):

I am in the process of developing and testing this module, and adding promises. I also found some bugs. Anyone that wants to use this module probably better wait for 2.x.

Design

image of local file: Jifdb-design-v1.2.svg

Installation

Info on: https://www.npmjs.com/package/jifdb

npm install jifdb --save

Usage

// do in <app.js> or <index.js>:
const jif_db = require('jifdb');
const jif_db = await jif_db.open_database({ db_path: path.join(__dirname, 'jifdb_data') });

// do in your model/script like <users.js>:
const jif_db = require('jifdb');
let users_coll = jif_db.open_collection({collection_name: "users"});

// CRUD on collection:
const new_user  = users.create({item:{ key1:"value1", key2:"value2" }});  // wil create unique _id property
const all_users = users.read();                                           // all items in collection
const get_user  = users.read({id:new_user.id});                           // read one item

// Jifdb public methods:
Jifdb.open_database({db_path:db_path})
Jifdb.close_database()
Jifdb.open_collection({collection_name: "coll_name"}) => returns: a Jifcollection
Jifdb.close_collection({collection_name: "coll_name"})
Jifdb.delete_collection({collection_name: "coll_name"})

// Jifcollection public methods (CRUD):
Jifcollection.create({item:{ key1:"value1", key2:"value2" }})
Jifcollection.read({id: id})
Jifcollection.update({id: id})
Jifcollection.delete({id: id})
Jifcollection.save()

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.