0.0.5 • Published 2 years ago

imicros-flow-map v0.0.5

Weekly downloads
5
License
MIT
Repository
github
Last release
2 years ago

imicros-flow-map

Moleculer service for transformation JSON to JSON with JSONata

Installation

$ npm install imicros-flow-map --save

Dependencies

Required mixins (or a similar mixin with the same notation) for the Moleculer sevice:

Usage

Usage map

const { map } = require("imicros-flow-map");

// JSON template
const template = "{ 'my favorite': $.elements[id=2].name }";

// data
const data = {
    elements: [{
      id: 1,
      name: "banana"
    },{
      id: 2,
      name: "pear"
    },{
      id: 3,
      name: "apple"
    }]
};

let result = map(template, data);
/*
{
  "my favorite": "pear"
}
*/

Usage JasonMap service

const { ServiceBroker } = require("moleculer");
const { MinioMixin } = require("imicros-minio");
const { JsonMap } = require("imicros-map");

broker = new ServiceBroker({
    logger: console
});
broker.createService(JsonMap, Object.assign({ 
    mixins: [MinioMixin()]
}));
broker.start();

Actions template service

  • map { name, data } => result
  • map { template, data } => result
0.0.5

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.4

2 years ago

0.0.1

3 years ago