Skip to content

yantrab/nosql-normalizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nosql-normalizer

Reduce json object, by normalized it, to speed up your rest api.

What nosql-normalizer does

If you are using nosql database, and your table is look like this, so do normalize of this json, exlude all entities to a nother store object. See here the result.

Why should i use this package

  1. decrease response size, in my example, 674 kb became to 140kb; end response time 53ms became to 33ms.
  2. decrease memory size, if you store the object in memory, using normalize and de-normalize, does decrease memory size dramaticaly. in my exmple, 755780B became to 189296B.

Usage

install by npm

npm i nosql-normalizer

normalize response data by:

import { normalize, denormalize } from 'nosql-normalizer';
normalize(result, //* id property, defualt :'_id'*//);

de-normalize response data by

denormalize(response);

Use it as express middleware

    resolve = (req, res, next) => {
       const json = res.json;
       res.json = (result) => {
           return json.call(res, normalize(result));
       };
       return next();
   }

About

Speed up you rest api by normalize the response.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published