imicros-flow-map
v0.0.5
Published
JSON mapper for usage in imicros-flow
Downloads
12
Readme
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