imicros-flow-map

0.0.5 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i imicros-flow-map

Weekly Downloads

5

Version

0.0.5

License

MIT

Unpacked Size

25.3 kB

Total Files

10

Last publish

Collaborators

  • al66