Skip to content
/ jifdb Public

a 'JSON File Database' is a minimalist CommonJS module using a JSON file backend and CRUD accessors

License

Notifications You must be signed in to change notification settings

jdg71nl/jifdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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()

About

a 'JSON File Database' is a minimalist CommonJS module using a JSON file backend and CRUD accessors

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published