10 minutes
estimated time of completion.
Note
Node.js is only available on InterSystems IRIS v2019.2+.
Note
If you don’t have InterSystems IRIS set up yet, get a free development sandbox here.
Setup
- Verify you have an instance of InterSystems IRIS and an IDE that supports Node.js (such as Visual Studio Code). If you are using AWS, Azure, or GCP, verify that you have followed the steps to change the password for InterSystems IRIS.
- Load sample stock data into InterSystems IRIS:
- Clone or download this repository:
https://github.com/intersystems/Samples-Stock-Data
. This repository has a folder named , which contains all files needed to load the sample stock data. - In the Management Portal, navigate to
DemoStockCls.xml
andStocksUtil.xml
files into the USER namespace from the data folder.
and import - In the InterSystems IRIS Terminal, type the following command. Replace
repo_home
with the directory of Sample-Stock-Data repo that you recently cloned:do ##class(Demo.Stock).LoadData("repo_home/data/all_stocks_1yr.csv")
- Clone or download this repository:
- To get the sample Node.js code, download or clone the following repo into your IDE:
http://github.com/intersystems/quickstarts-nodejs
- In your IDE:
- Open the Node.js folder you recently cloned.
- Open
connections.config
file and modify theIP
andpassword
to be the correct values for your InterSystems IRIS instance. Although port and username are most likely the defaults, you should verify that the values are correct.
- In the Terminal of your IDE:
- Navigate to the sample code directory:
cd Solutions
- Navigate to the sample code directory:
- Install the necessary modules:
npm install --save intersystems-iris-native
to install IRIS Native API for Node.js modulenpm install readline-sync
for handling user inputnpm install file-system
for handling filesystem
- In your IDE:
- You should now have several Node.js classes that use the Native API. To run a file, type
node filename.js
, replacingfilename.js
with the name of the file you want to run.
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.
- 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})
- Run
nodeplaystockTask5.js
. 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.