You should have a look at the ewd-document-store npm module, this module contains high-level global access methods for Node.js. Btw, it's the underlying module used also by the QEWD.js back-end server for Node.js & Caché/IRIS.
E.g. you can iterate easily over your Customer global using:
var DocumentStore = require('ewd-document-store');
// put the appropriate irisXXX.node version inside node_modules
// and rename it to iris.node
var iface = require('iris');
var db = new iface.IRIS();
// Change these parameters to match your IRIS system:
var ok = db.open({
path: '/opt/iris/mgr',
username: '_SYSTEM',
password: 'SYS',
namespace: 'USER'
});
// bind the iris.node db instance to the high-level DocumentStore
var documentStore = new DocumentStore(db);
// instantiate a DocumentNode object to access the Customer global
var customerNode = new documentStore.DocumentNode(‘Customer’);
// iterate over customerId's using the forEachChild() method
customerNode.forEachChild(function (customerId) {
console.log(customerId); // will output 1, 2, 3, ...
// access sub-nodes using the $() method using method chaining
// and retrieve the city using the value property
if (customerNode.$(customerId).$('Address').$('1').value == 'London') {
// do what's needed with a London customer ...
}
});
// probably, customerNode.forEachLeafNode() is even more appropriate
// close the db connection to IRIS
db.close();
I haven't completely tested the code above, but you should get the idea. The module provides you with some cool high-level NoSQL access methods to iterate over a global in JavaScript. The methods of DocumentStore and DocumentNode allow you to access very large globals without size and/or memory limitations (see documentation).
- Log in to post comments
