Node.js QuickStart

time to complete
10 minutes

Node.js is one of the most commonly used programming languages due to its strong performance and scalability.

InterSystems IRIS® Native API for Node.js lets your application directly access the underlying data structure within InterSystems IRIS (known as globals) as well as call ObjectScript methods and routines.

To review ways to connect your application to InterSystems IRIS data platform, watch the video above.

The exercise below will walk you through the set up and execution of using Node.js to connect to InterSystems IRIS.

Node.js is only available on InterSystems IRIS v2019.2+.

The Native API can be used to store data in your own custom structures to InterSystems IRIS. It can also be used to run existing InterSystems IRIS methods or routines. For this exercise, you will see how Native API allows your Node.js application to interact directly with InterSystems IRIS.

Launch the development sandbox and click the IDE link.

Set up

First, make sure you have an instance of InterSystems IRIS and a multi-language IDE ready to go.

Need InterSystems IRIS?
Get a free, online development sandbox here. Log in with your InterSystems login account, or register for one below.

  1. Clone the quickstarts-nodejs repo into the /home/project directory in the cloud IDE whose settings are above. Open the IDE -- cannot display value - please provision a sandbox. Then in the IDE’s terminal window:
    cd /home/project
    git clone -b try-iris
  2. Using the Explorer pane (the file browser encompassing the left side of the IDE), open the quickstarts-nodejs folder, and then the Solutions folder. Then open the connections.config file and change the value of IP to -- cannot display value - please provision a sandbox and the value of port to -- cannot display value - please provision a sandbox.
  3. Install the necessary modules:
    • cd /home/project/quickstarts-nodejs/Solutions to navigate to the sample code directory
    • npm install --save intersystems-iris-native to install IRIS Native API for Node.js module
    • npm install readline-sync for handling user input
    • npm install file-system for handling the file system

Use the Native API to store and exercise a custom structure

Use the Native API to store to a custom structure and call methods or routines.

  1. Open nodeplaystockTask5.js to view the Native API code. You will notice the connection string uses these variables to connect: const connection = irisnative.createConnection({host: ip, port: port, ns: namespace, user: username, pwd: password})
  2. Run nodeplaystocksTask5.js:
    cd /home/project/quickstarts-nodejs/Solutions
    node nodeplaystocksTask5.js
  3. This code stores stock data in a custom data structure.
    • Run option 2: Store the stock data in a custom structure.
    • Run option 3: Retrieve and view the stock data from this custom structure.
    • Run option 4: Call population methods within InterSystems IRIS to generate better information for trades.
    • Run option 5: Print the version of IRIS to the screen. This is retrieved by calling a routine within InterSystems IRIS.
    • Run option 6: Quit.
With the Native API, you can efficiently store data in your own custom data structure. Additionally, you can call class methods and routines from within InterSystems IRIS using the Native API.