larvitproduct
Generic product module for nodejs.
Product data structure:
Installation
npm i --save larvitproduct
Usage
Create new instance of the lib
const ProductLib = ;const libOptions = {};libOptionslog = log; // logging instance (see Log in larvitutils library)libOptionsesIndexName = 'anEsIndexName';libOptionsmode = 'noSync'; // see larvitamsync librarylibOptionsintercom = 'loopback interface';libOptionsamsync = {};libOptionsamsynchost = null;libOptionsamsyncminPort = null;libOptionsamsyncmaxPort = null;libOptionselasticsearch = es; // instance of elasticsearch.Clientconst productLib = libOptions {if err throw err;// ProductLib instance created!};
Add a new product
const ProductLib Product = ; // Create productLib instance of ProductLib const product = 'productLib': productLib 'log': optionalLoggingInstance;// Or, use the factory function in ProductLib:const otherProduct = productLib; // will initiate with log instance from productLib productattributes = 'name': 'Test product #69' 'price': 99 'weight': 14 'color': 'blue' 'green'; product;