node-red-contrib-iris

1.0.9 • Public • Published

node-red-contrib-irisLogo

node-red-contrib-iris

An interface for Node-RED to InterSystems IRIS Data Platform.



Requirements


Installation

Install the Node-RED package

Either use the Node-RED Menu - Manage Palette - Install menu, or run the following command in your Node-RED user directory - typically ~/.node-red

npm install node-red-contrib-iris

Import Native API

In the ~/.node-red/settings.js file add module in (already existing) functionGlobalContext:

functionGlobalContext: {
    // os:require('os'),
    iris: require('./node_modules/node-red-contrib-iris/intersystems-iris-native'),
}

You can find the API package under .node-red/node_modules/node-red-contrib-iris/intersystems-iris-native. Please check the README file for supported operating systems. If your OS is not supported you can get the API from your Intersystems IRIS instance under: ~/IRIS/dev/nodejs/intersystems-iris-native.

See the documentation for how to load additional modules into Node-RED.

Download Node.IRISInterface

Go to raw.githubusercontent. Do a right click on the page and choose Save Page As... . Afterwards go to the InterSystems Management Portal and navigate to System Explorer > Classes and click on Import. There you select the file you just downloaded and click Import. When you only operate in one namespace, import the class into this namespace. When you have multiple namespaces you want to have access to, map the class to namespace %ALL.


Connect to IRIS

Set connection properties via the node properties. The Node will build a connection when you deploy and will hold that connection up until you redeploy or disconnect manually.

NodeProperties

You can set the default properties in ~/.node-red/node_modules/node-red-contrib-iris/ServerProperties.json. Or use the SetServerProperties flow under Import > Examples > node-red-contrib-iris > SetServerProperties.


Usage

The nodes are secure against SQL injection by parametrize the statements. Pass the SQL statement as a string in the msg.data field and the node will parameterize the statement itself.

msg.data = "SELECT * FROM NodeRed.Person WHERE Age >= 42 AND Name = 'Max' ";

Or a parameterized statement:

msg.data = {
    sql: 'SELECT * FROM NodeRed.Person WHERE Age >= ? AND Name = ? ',
    values: [42, 'Max'],
};

Nodes

  • IRIS - A Node for executing DML statements such as SELECT, UPDATE, INSERT and DELETE and DDL statements such as CREATE, ALTER and DROP in Intersystems IRIS.
  • IRIS_CREATE - Creates a class in Intersystems IRIS.
  • IRIS_DELETE_CLASS - Deletes a class in Intersystems IRIS.
  • IRIS_INSERT - A Node for only SQL-INSERT-Statements. Can also generate the class, if it does not already exists, based on the statement.
  • IRIS_OO - Can insert a hierarchical JSON-Object.
  • IRIS_CALL - Call Intersystems IRIS classmethods.

See Node description for further informations.


Bugs

  • Currently does not work in Docker Container!
  • The statement will be parametrized wrong if whitespaces and commas used in strings. Please parametrize the Statement before. Example:

Does not work:

msg.data = "SELECT * FROM NodeRed.Person WHERE Name = 'Smith, John'";

But this will work:

msg.data = {
    "sql":"SELECT * FROM NodeRed.Person WHERE Name = ?,
    "values":["Smith, John"]
    }


npm
GitHub
nodered.org
CHANGELOG
InterSystems Developer Community


by Philipp Bonin
Powered by InterSystems.

Package Sidebar

Install

npm i node-red-contrib-iris

Weekly Downloads

2

Version

1.0.9

License

MIT

Unpacked Size

16.9 MB

Total Files

66

Last publish

Collaborators

  • pbonin