JSPM

  • Created
  • Published
  • Downloads 22
  • Score
    100M100P100Q60233F
  • License MIT

An Object Document Mapper to handle JSON on the fly for NodeJS

Package Exports

  • fly-json-odm

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fly-json-odm) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

fly-json-odm

NPM

npm version Build Status Coverage Status Known Vulnerabilities dependencies Status License NPM download/month NPM download total
An Object Document Mapper to handle JSON on the fly for NodeJS

Background

fly-json-odm is the ODM library to handle JSON on the fly like NOSQL does. You are able to make manipulation of JSON like ORM. For example is to do Insert, Read, Update, Modify, Delete, Join and Query. When you are develop in microservices architecture, you will face up that everything should be handle from rest json via each services, because you can not access directly into the database.

Limitation

This library was created to handle JSON for modification/manipulation only and any data will be processed and saved in memory for temporary (On-The-Fly). Not support for to use with any database server also we don't provide feature how to read JSON from file, stream or something like that.

Install using NPM

$ npm install fly-json-odm

Usage

const FlyJson = require('fly-json-odm');

var nosql = new FlyJson();

// example data json
var data = [
    {user_id:1,name:'budi',age:10},
    {user_id:5,name:'wawan',age:20},
    {user_id:3,name:'tono',age:30}
];

// Synchronous
var result = nosql.set(data)
  .where('id',5)
  .exec();
console.log(result);

// Asynchronous
nosql.promisify((builder) => {return builder}).then((table) => {
  var result = table.set(data)
    .where('id',5)
    .exec();
  console.log(result);
});

Note:

  • Structure Data Table JSON must be an Array which is contains Object like example above.
  • fly-json-odm is synchronous as default.

Documentation

Documentation detail about CRUD, Query, Join, Transform and for more example is available at here.

Unit Test

If you want more example, you can play around with unit test.

$ npm test