Tutorial: API Reference

API Reference

Native API Quick Reference for Node.js

This chapter is a quick reference for the following classes, which are all members of module "intersystems-iris-native"

  • Class Connection provides a connection to the server.
  • Class Iris provides the main functionality.
  • Class Iterator provides methods to navigate a global array.
  • Class IRISGlobalNode provides a virtual dictionary for a global array.
  • Class IRISList provides all the basic iris list functionality.
  • Class IRISObject acts as a server object proxy.
  • Class IRISReference can be used to pass function arguments by reference.

NOTE:
This chapter is intended as a convenience for readers of this book, but it is not the definitive reference for the Native API. For the most complete and up-to-date information on these classes, read the class documentation available with this guide.

List of Methods by Usage

Class Connection

The Connection class encapsulates a connection to the server. Instances of Connection are created and connected to the server by "intersystems-iris-native" method createConnection().

Class Iris

The Iris class provides most of the Native API functionality. Instances of Iris are created by Connection.createIris(). Methods are listed below, organized by usage:

Class Iris: Global Iteration and Management

  • getAPIVersion() — returns the version string for this version of the Native API.
  • getServerVersion() — returns the version string for the currently connected server.
  • increment(...) — increments the value of a global node by the specified amount.
  • nextSubscript(...) — gets the next $order subscript value of a global array node as a string, returns null if end.
  • isDefined(...) — checks if a global node exists, and if it contains data.
  • node(...) — returns an instance of IRISGlobalNode
  • iterator(...) — returns an instance of Iterator
  • kill(...) — kills the global node including any descendants.
  • set(...) — sets the value of a global node.

Class Iris: Node Value Accessors

Class Iris: Transactions and Locking

  • lock(...) — performs an incremental lock on the global, returns true on success.
  • unlock(...) — performs an immediate or deferred unlock on the global.
  • releaseAllLocks() — releases all locks associated with the session.
  • getTLevel(...) — returns the current transaction level (0 if not in a transaction).
  • tCommit() — commits the current transaction and decrements the transaction level.
  • tRollback() — rolls back all open transactions in the session.
  • tRollbackOne() — rolls back the current level transaction only.
  • tStart() — starts a transaction and increments the transaction level.

Class Iris: ClassMethod and Function Calls

  • classMethodValue(...) — calls a user defined ObjectScript method and gets the returned value
  • classMethodObject(...) — calls a user defined ObjectScript method and gets the returned value
  • classMethodBoolean(...) — calls a user defined ObjectScript method and gets the returned value as a boolean
  • classMethodBytes(...) — calls a user defined ObjectScript method and gets the returned value as a byte array
  • classMethodDecimal(...) — calls a user defined ObjectScript method and gets the returned value as a decimal
  • classMethodIRISList(...) — calls a user defined ObjectScript method and gets the returned value as IRISList
  • classMethodBigInt(...) — calls a user defined ObjectScript method and gets the returned value a bigint
  • classMethodNumber(...) — calls a user defined ObjectScript method and gets the returned value a number
  • classMethodString(...) — calls a user defined ObjectScript method and gets the returned value as a string
  • classMethodVoid(....) — calls a user defined ObjectScript method, ignoring any returned value
  • function(...) — calls a function of a user defined ObjectScript routine and gets the returned value
  • functionObject(...) — calls a function of a user defined ObjectScript routine and gets the returned value
  • functionBoolean(...) — calls a function of a user defined ObjectScript routine and gets the returned value as boolean
  • functionBytes(...) — calls a function of a user defined ObjectScript routine and gets the returned value as byte array
  • functionDecimal(...) — calls a function of a user defined ObjectScript routine and gets the returned value as a decimal
  • functionBigInt(...) — calls a function of a user defined ObjectScript routine and gets the returned value as a bigint
  • functionNumber(...) — calls a function of a user defined ObjectScript routine and gets the returned value as a number
  • functionIRISList(...) — calls a function of a user defined ObjectScript routine and gets the returned value as an IRISList
  • functionString(...) — calls a function of a user defined ObjectScript routine and gets the returned value as a string
  • procedure(...) — calls a procedure of a user defined ObjectScript routine

Class Iterator

The Iterator class provides methods to iterate over a set of nodes. Instances of Iterator are created by Iris.iterator().

  • entries() — sets return type to an array containing subscript and node value.
  • keys() — sets return type to return the node subscript (key) only.
  • next() — positions the iterator at the next sibling node.
  • nodes() — sets return type to return the node sub-node only.
  • nodeEntries() — sets return type to return both subscript and sub-node.
  • reversed() — toggles iteration between forward and reverse collation order.
  • startFrom() — sets starting position to the specified subscript.
  • subscripts() — sets return type to return the node subscript (key) only.
  • values() — sets return type to return the node value only.

Class IRISGlobalNode

The IRISGlobalNode class provides an iterable interface that behaves like a virtual dictionary representing the immediate children of a global node. Instances of IRISGlobalNode are created by Iris.node().

Class IRISGlobalNode: Value manipulation

  • get(...) — returns a specified value from an IRISGlobalNode object.
  • node(...) — returns an IRISGlobalNode object that represents the subnode at a given subscript.
  • set(...) — adds or updates the value of a specified subscript in the IRISGlobalNode.
  • clear() — completely deletes the IRISGlobalNode from the IRIS server.
  • delete(...) — removes the specified value from the IRISGlobalNode object by subscript.

Class IRISGlobalNode: Information

  • has(...) — returns a boolean indicating whether a value with the specified subscript exists or not.
  • size() — returns the number of subscript-value pairs in the IRISGlobalNode.

Class IRISGlobalNode: Other

  • forEach(...) — executes a provided function once per each subscript/value pair in the IRISGlobalNode.
  • slice(...) — slices the current node and returns a new node with subscripts that start at the startSubscript and end at the endSubscript (exclusive).

Class IRISGlobalNode: Iterators

  • entries() — Returns an Iterator object of the current IRISGlobalNode which can be iterated over to yield subscript-value pairs.
  • keys() — Returns an Iterator object of the current IRISGlobalNode which can be iterated over to yield only subscripts (keys).
  • nodeEntries() — Returns an Iterator object of the current IRISGlobalNode which can be iterated over to yield subscript-subnode pairs.
  • nodes() — Returns a reverse Iterator object of the current IRISGlobalNode which can be iterated over to yield only subnodes.
  • reversed() — Returns an Iterator object of the current IRISGlobalNode which can be iterated over to yield subscript-value pairs.
  • subscripts() — Returns an Iterator object of the current IRISGlobalNode which can be iterated over to yield only subscripts (keys).
  • values() — returns an Iterator object of the current IRISGlobalNode which can be iterated over to yield only values.

Class IRISList

The IRISList class provides an interface to interact with IRIS $LIST data. Instances of Iterator are created by the class constructor IRISList(...).

Class IRISList: List Information

  • size() — returns the total size (number of bytes) of the list.
  • count() — returns the number of data elements in the list.
  • equals() — compares a list to the current list.
  • getBuffer() — returns a Buffer that contains the $LIST format of all the data elements in the list.
  • toString() — returns a string containing the formatted list value.

Class IRISList: Add / Update Element

  • add(...) — adds a data element at the end of the list. Returns back the list for chaining.
  • set(...) — changes the data element at the specified index to a new value. Returns back the list for chaining.
  • remove(...) — removes the list element at the specified index from the list. Returns back the list for chaining.
  • clear() — removes all data elements from the list. Returns back the list for chaining.

Class IRISList: Get Element

  • get(...) — gets the list element at the specified index.
  • getBoolean(...) — gets the list element at the specified index as a boolean.
  • getBytes(...) — gets the list element at the specified index as a Buffer.
  • getDecimal(...) — gets the list element at the specified index as a Decimal.
  • getBigInt(...) — gets the list element at the specified index as a bigint number.
  • getNumber(...) — gets the list element at the specified index as a number.
  • getList(...) — gets the list element at the specified index as an IRISList.
  • getIRISList(...) — getList alias. gets the list element at the specified index as an IRISList.
  • getString(...) — gets the list element at the specified index as a string.

Class IRISObject

The IRISObject class represents a proxy object created on behalf of IRIS object. IRISObjects are created when a function/method returns an IRIS object, at which point the proxy gets instantiated. Methods are listed below, organized by usage:

  • close() — closes the proxy object.

Class IRISObject: Property Management

  • set(...) — sets the value of a global node.

Class IRISObject: Property Accessors

Class IRISObject: Function Calls

  • invoke(...) — invokes a method of the IRISObject object that returns a value.
  • invokeObject(...) — invokes a method of the IRISObject object that returns a value.
  • invokeBoolean(...) — invokes a method of the IRISObject object that returns a value as boolean.
  • invokeBytes(...) — invokes a method of the IRISObject object that returns a value as a byte array.
  • invokeDecimal(...) — invokes a method of the IRISObject object that returns a value as a decimal.
  • invokeBigInt(...) — invokes a method of the IRISObject object that returns a value as a bigint.
  • invokeNumber(...) — invokes a method of the IRISObject object that returns a value as an number.
  • invokeIRISList(...) — invokes a method of the IRISObject object that returns a value as a list.
  • invokeString(...) — invokes a method of the IRISObject object that returns a value as a string.
  • invokeVoid(...) — invokes a method of the IRISObject object that does not return a value.

Class IRISReference

The IRISReference class is used to call method/routine with pass-by-reference arguments. Instances of IRISReference are created by the class constructor, IRISReference(...)

  • setValue(...) — sets the value the IRISReference object referes to.
  • getValue() — gets the value of this IRISReference object.
  • setType(...) — changes the (suggested) type of the value the IRISReference object referes to.
  • getType() — gets the (suggested) type of the value of this IRISReference object.
  • getBoolean() — gets the value of this IRISReference object as boolean
  • getBytes() — gets the value of this IRISReference object as Buffer
  • getDecimal() — gets the value of this IRISReference object as Decimal
  • getBigInt() — gets the value of this IRISReference object as bigint
  • getNumber() — gets the value of this IRISReference object as number
  • getObject() — gets the value of this IRISReference object
  • getString() — gets the value of this IRISReference object as string
  • getIRISList() — gets the value of this IRISReference object as IRISList
  • toString() — gets the string representation of the IRISReference object

Class Connection

Class Connection is a member of "intersystems-iris-native". Instances of Connection are created by intersystems-iris-native method createConnection().

createConnection()

intersystems-iris-native createConnection() establishes a connection to the server.

  (static) createConnection(connectionInfo) → {"intersystems-iris-native".Connection}

parameters:

  • connectionInfo — Object containing connection properties. Valid properties of connectionInfo are:
    • host — required string containing the address of the host machine
    • port — required integer specifying the port number
    • ns — required string containing the database namespace
    • user — string containing the user name
    • pwd — string containing the password
    • sharedmemory — boolean indicating whether to use shared memory if available (default is true).
    • timeout — integer specifying the number of milliseconds to wait before the connection attempt times out (default is 10).
    • logfile — string specifying the full path and name of a log file for this connection. If not specified, no log file will be written.
    • sslcontext — the path to the file that contains the sslcontext configuration if the connection needs to be secure.

For example, the following code fragment defines all properties of connectionInfo and creates an instance of Connection named conn:

      const IRISNative = require('intersystems-iris-native')

      let connectionInfo = {
        host: '127.0.0.1',
        port: 1972,
        ns: 'USER',
        user: 'username',
        pwd: 'password',
        sharedmemory: true
        timeout: 5,
        logfile: 'C:\temp\mylogfile.log'
      };

      const conn = IRISNative.createConnection(connectionInfo);

close()

Connection.close() closes the connection to the server.

    close()

createIris()

Connection.createIris() returns an instance of class Iris connected to the server by this Connection.

    createIris() → {"intersystems-iris-native".Iris}

isClosed()

Connection.isClosed() returns true if the connection is currently closed, false if the connection is currently open.

    isClosed() → {boolean}

isUsingSharedMemory()

Connection.isUsingSharedMemory() returns true if the connection is using shared memory, false if it is not.

    isUsingSharedMemory() → {boolean}

Class Iris

Class Iris is a member of "intersystems-iris-native". Instances of Iris are created by calling Connection.createIris().

The main IRIS Native API is implemented by the IRIS class. Functions implemented by IRIS are global functions, function and procedure calls, locks, and transactions.

classMethodBoolean()

Iris.classMethodBoolean() calls a class method, passing 0 or more arguments and returning the called method’s return value as a boolean or null if empty string returned from IRIS.

    classMethodBoolean(className, methodName, ...args) → {boolean|null}

parameters:

  • className — fully qualified name of the class to which the called method belongs.
  • methodName — name of the class method.
  • args — 0 or more method arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.

classMethodBytes()

Iris.classMethodBytes() calls a class method, passing 0 or more arguments and returning the called method’s return value as a Buffer or null if empty string returned from IRIS.

    classMethodBytes(className, methodName, ...args) → {Buffer|null}

parameters:

  • className — fully qualified name of the class to which the called method belongs.
  • methodName — name of the class method.
  • args — 0 or more method arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.

classMethodDecimal()

Iris.classMethodDecimal() calls a class method, passing 0 or more arguments and returning the called method’s return value as a Decimalor null if empty string returned from IRIS.

    classMethodDecimal(className, methodName, ...args) → {Decimal|null}

parameters:

  • className — fully qualified name of the class to which the called method belongs.
  • methodName — name of the class method.
  • args — 0 or more method arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.

classMethodBigInt()

Iris.classMethodBigInt() calls a class method, passing 0 or more arguments and returning the called method’s return value as a bigint number or null if empty string returned from IRIS.

    classMethodBigInt(className, methodName, ...args) → {bigint|null}

parameters:

  • className — fully qualified name of the class to which the called method belongs.
  • methodName — name of the class method.
  • args — 0 or more method arguments of supported types (see "Calling ObjectScript Methods and Functions". Trailing arguments may be omitted.

classMethodIRISList()

Iris.classMethodIRISList() calls a class method, passing 0 or more arguments and returning the called method’s return value as an IRISList. If empty string returned from IRIS the list will be empty.

    classMethodIRISList(className, methodName, ...args) → {IRISList}

parameters:

  • className — fully qualified name of the class to which the called method belongs.
  • methodName — name of the class method.
  • args — 0 or more method arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.

classMethodNumber()

Iris.classMethodNumber() calls a class method, passing 0 or more arguments and returning the called method’s return value as a number or null if empty string returned from IRIS.

    classMethodNumber(className, methodName, ...args) → {number|null}

parameters:

  • className — fully qualified name of the class to which the called method belongs.
  • methodName — name of the class method.
  • args — 0 or more method arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.

classMethodObject()

Iris.classMethodObject() calls a class method, passing 0 or more arguments and returning the called method’s return value or null if empty string returned from IRIS.

    classMethodObject(className, methodName, ...args) → {any}

parameters:

  • className — fully qualified name of the class to which the called method belongs.
  • methodName — name of the class method.
  • args — 0 or more method arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.

classMethodValue()

Iris.classMethodValue() calls a class method, passing 0 or more arguments and returning the called method’s return value or null if empty string returned from IRIS.

    classMethodValue(className, methodName, ...args) → {any}

parameters:

  • className — fully qualified name of the class to which the called method belongs.
  • methodName — name of the class method.
  • args — 0 or more method arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.

classMethodString()

Iris.classMethodString() calls a class method, passing 0 or more arguments and returning the called method’s return value as a string or null if empty string returned from IRIS.

    classMethodString(className, methodName, ...args) → {string||null}

parameters:

  • className — fully qualified name of the class to which the called method belongs.
  • methodName — name of the class method.
  • args — 0 or more method arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.

classMethodVoid()

Iris.classMethodVoid() calls a class method, passing 0 or more arguments and returning nothing.

    classMethodVoid(className, methodName, ...args)

parameters:

  • className — fully qualified name of the class to which the called method belongs.
  • methodName — name of the class method.
  • args — 0 or more method arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.

function()

Iris.function() calls a function, passing 0 or more arguments and returning the called function’s return value which is null if empty string returned from IRIS.

    function(functionName, routineName, ...args) → {any}

parameters:

  • functionName — name of the function to call
  • routineName — name of the routine containing the function.
  • args — 0 or more function arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.
⚠ See warning note at the end of this section.

functionBoolean()

Iris.functionBoolean() calls a function, passing 0 or more arguments and returning the called function’s return value as a boolean or null if empty string returned from IRIS.

    functionBoolean(functionName, routineName, ...args) → {boolean|null}

parameters:

  • functionName — name of the function to call
  • routineName — name of the routine containing the function.
  • args — 0 or more function arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.
⚠ See warning note at the end of this section.

functionBytes()

Iris.functionBytes() calls a function, passing 0 or more arguments and returning the called function’s return value as a Buffer or null if empty string returned from IRIS.

    functionBytes(functionName, routineName, ...args) → {Buffer|null}

parameters:

  • functionName — name of the function to call
  • routineName — name of the routine containing the function.
  • args — 0 or more function arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.
⚠ See warning note at the end of this section.

functionDecimal()

Iris.functionDecimal() calls a function, passing 0 or more arguments and returning the called function’s return value as a Decimal or null if empty string returned from IRIS.

    functionDecimal(functionName, routineName, ...args) → {Decimal|null}

parameters:

  • functionName — name of the function to call
  • routineName — name of the routine containing the function.
  • args — 0 or more function arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.
⚠ See warning note at the end of this section.

functionNumber()

Iris.functionNumber() calls a function, passing 0 or more arguments and returning the called function’s return value as a number or null if empty string returned from IRIS.

    functionNumber(functionName, routineName, ...args) → {number|null}

parameters:

  • functionName — name of the function to call
  • routineName — name of the routine containing the function.
  • args — 0 or more function arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.
⚠ See warning note at the end of this section.

functionBigInt()

Iris.functionBigInt() calls a function, passing 0 or more arguments and returning the called function’s return value as a bigint number or null if empty string returned from IRIS.

    functionBigInt(functionName, routineName, ...args) → {bigint|null}

parameters:

  • functionName — name of the function to call
  • routineName — name of the routine containing the function.
  • args — 0 or more function arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.
⚠ See warning note at the end of this section.

functionIRISList()

Iris.functionIRISList() calls a function, passing 0 or more arguments and returning the called function’s return value as an IRISList. If empty string returned from IRIS the list will be empty.

    functionIRISList(functionName, routineName, ...args) → {IRISList}

parameters:

  • functionName — name of the function to call
  • routineName — name of the routine containing the function.
  • args — 0 or more function arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.
⚠ See warning note at the end of this section.

functionObject()

Iris.functionObject() calls a function, passing 0 or more arguments and returning the called function’s return value which is null if empty string returned from IRIS.

    functionObject(functionName, routineName, ...args) → {any}

parameters:

  • functionName — name of the function to call
  • routineName — name of the routine containing the function.
  • args — 0 or more function arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.
⚠ See warning note at the end of this section.

functionString()

Iris.functionString() calls a function, passing 0 or more arguments and returning the called function’s return value as string or null if empty string returned from IRIS.

    functionString(functionName, routineName, ...args) → {string|null}

parameters:

  • functionName — name of the function to call
  • routineName — name of the routine containing the function.
  • args — 0 or more function arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.
⚠ See warning note at the end of this section.

get()

Iris.get() returns the value of the global node. Returns null if node value is an empty string, or if the specified node address does not have a value.

    get(globalName, ...subscripts) → {any}

parameters:

  • globalName — global name
  • subscripts — array of subscripts specifying the target node

getAPIVersion()

Iris.getAPIVersion() returns the Native API version string.

    getAPIVersion() → {string}

getBoolean()

Iris.getBoolean() returns the node value as a boolean. Returns false if node value is an empty string, or null if the specified node address does not have a value.

    getBoolean(globalName, ...subscripts) → {boolean|null}

parameters:

  • globalName — global name
  • subscripts — array of subscripts specifying the target node

getBytes()

Iris.getBytes() returns the node value as an Buffer. Returns empty Buffer if node value is an empty string, or null if the specified node address does not have a value.

    getBytes(globalName, ...subscripts) → {Buffer|null}

parameters:

  • globalName — global name
  • subscripts — array of subscripts specifying the target node

getDecimal()

Iris.getDecimal() returns the node value as a Decimal. Returns Decimal(0) if node value is an empty string, or null if the specified node address does not have a value.

    getDecimal(globalName, ...subscripts) → {Decimal|null}

parameters:

  • globalName — global name
  • subscripts — array of subscripts specifying the target node

getBigInt()

Iris.getBigInt() returns the node value as a bigint number. Returns 0n if node value is an empty string, or null if the specified node address does not have a value.

    getBigInt(globalName, ...subscripts) → {bigint|null}

parameters:

  • globalName — global name
  • subscripts — array of subscripts specifying the target node

getList()

Iris.getList() returns the node value as an IRISList. Returns empty list if node value is an empty string, or null if the specified node address does not have a value.

    getList(globalName, ...subscripts) → {IRISList|null}

parameters:

  • globalName — global name
  • subscripts — array of subscripts specifying the target node

getIRISList()

Iris.getIRISList() returns the node value as an IRISList. Returns empty list if node value is an empty string, or null if the specified node address does not have a value. Alias of getList().

    getIRISList(globalName, ...subscripts) → {IRISList|null}

parameters:

  • globalName — global name
  • subscripts — array of subscripts specifying the target node

getNumber()

Iris.getNumber() returns the node value as a number. Returns 0 if node value is an empty string, or null if the specified node address does not have a value.

    getNumber(globalName, ...subscripts) → {number|null}

parameters:

  • globalName — global name
  • subscripts — array of subscripts specifying the target node

getObject()

Iris.getObject() returns the value of the global node. Returns null if node value is an empty string, or if the specified node address does not have a value.

    getObject(globalName, ...subscripts) → {any}

parameters:

  • globalName — global name
  • subscripts — array of subscripts specifying the target node

getServerVersion()

Iris.getServerVersion() returns the version string of the currently connected server.

    getServerVersion() → {string}

getString()

Iris.getString() returns the node value as a string. Returns string with length 0 if node value is an empty string, or null if the specified node address does not have a value.

    getString(globalName, subscripts) → {string|null}

parameters:

  • globalName — global name
  • subscripts — array of subscripts specifying the target node

getTLevel()

Iris.getTLevel() returns the level of the current nested transaction. Returns 1 if there is only a single transaction open. Returns 0 if there are no transactions open. This is equivalent to fetching the value of the $TLEVEL special variable. See “Transactions and Locking” for more information and examples.

    getTLevel() → {number}

increment()

Iris.increment() increments the specified node by the integer value of incrementBy. If the specified node address does not have a value, then the node will be created and its value set to the value of incrementBy. Returns the new integer value of the node.

    increment(incrementBy, globalName, ...subscript) → {number}

parameters:

  • incrementBy — numeric value to which to set this node (null value sets global to 0, decimal value will be truncated to an integer).
  • globalName — global name
  • subscripts — array of subscripts specifying the target node

isDefined()

Iris.isDefined() checks if a global exists and contains data (see $DATA). Returns 0 if the node does not exist, 1 if the global node exists and contains data. 10 if the node is valueless but has descendants. 11 if it has data and descendants. See “Testing for Child Nodes and Node Values” for more information and examples.

    isDefined(globalName, ...subscript) → {number}

parameters:

  • globalName — global name
  • subscripts — array of subscripts for this node

nextSubscript()

Iris.nextSubscript() gets the next $order subscript value of a global array node as a string, returns null if at the end. This method is similar to $ORDER in IRIS

    nextSubscript(reversed,globalName, ...subscript) → {null|string}

parameters:

  • reversed — true if reverse $order else false
  • globalName — global name
  • subscripts — array of subscripts for this node

node()

Iris.node() returns an IRISGlobalNode object (see "Class IRISGlobalNode") for the specified node.

    node(globalName, ...subscript) → {"intersystems-iris-native".IRISGlobalNode}

parameters:

  • globalName — global name
  • subscripts — array of subscripts specifying the target node

iterator()

Iris.iterator() returns an Iterator object (see "Class Iterator") for the specified node.

    iterator(globalName, ...subscript) → {"intersystems-iris-native".Iterator}

parameters:

  • globalName — global name
  • subscripts — array of subscripts specifying the target node

kill()

Iris.kill() kills the global node including any descendants.

    kill(globalName, ...subscript)

parameters:

  • globalName — global name
  • subscripts — array of subscripts for this node

lock()

Iris.lock() locks the global, returns true on success. This method performs an incremental lock, not the implicit unlock-before-lock feature that is offered in ObjectScript.

    lock(lockType, timeout, lockReference, ...subscript) → {boolean}

parameters:

  • lockMode — character S for shared lock or E for escalating lock. Use empty string for non or SE for both.
  • timeout — amount to wait to acquire the lock in seconds
  • lockReference — a string starting with a circumflex (^) followed by the global name (for example, ^myGlobal, not just myGlobal).

NOTE: Unlike the globalName parameter used by most methods, the lockReference parameter must be prefixed by a circumflex. Only lock() and unlock() use lockReference instead of globalName.

  • subscripts — array of subscripts for this node

procedure()

Iris.procedure() calls a procedure, passing 0 or more arguments.

    procedure(procedureName, routineName, ...args)

parameters:

  • procedureName — name of the procedure to call.
  • routineName — name of the routine containing the procedure
  • args — 0 or more procedure arguments of supported types (see "Calling ObjectScript Methods and Functions"). Trailing arguments may be omitted.
⚠ See warning note at the end of this section.

releaseAllLocks()

Iris.releaseAllLocks() releases all locks associated with the session.

    releaseAllLocks()

set()

Iris.set() sets the current node to a value of a supported datatype (or "" if the value is null):

    set(value, globalName, ...subscript)

parameters:

  • value — value of a supported datatype (null value sets global to "").
  • globalName — global name
  • subscripts — array of subscripts for this node

tCommit()

Iris.tCommit() commits the current transaction and decrements the transaction level. See "Transactions and Locking" for more information and examples.

    tCommit()

tRollback()

Iris.tRollback() rolls back all open transactions in the session. See "Transactions and Locking" for more information and examples.

    tRollback()

tRollbackOne()

Iris.tRollbackOne() rolls back the current level transaction only. If this is a nested transaction, any higher-level transactions will not be rolled back. See "Transactions and Locking" for more information and examples.

    tRollbackOne()

tStart()

Iris.tStart() starts a transaction and increments the transaction level. See "Transactions and Locking" for more information and examples.

    tStart()

unlock()

Iris.unlock() unlocks the global. This method performs an incremental unlock, not the implicit unlock-before-lock feature that is also offered in ObjectScript.

    unlock(lockMode, lockReference, ...subscript)

parameters:

  • lockMode — string containing lock type (S for Shared, E for Escalating or empty string for none. Note that SE is also valid input) and unlock type (I for an Immediate unlock or D for Deferred, which are mutually exclusive, so only one can be provided).
  • lockReference — a string starting with a circumflex (^) followed by the global name (for example, ^myGlobal, not just myGlobal).

NOTE: Unlike the globalName parameter used by most methods, the lockReference parameter must be prefixed by a circumflex. Only lock() and unlock() use lockReference instead of globalName.

  • subscripts — array of subscripts for this node

Class Iterator

Class Iterator is a member of "intersystems-iris-native". Instances of Iterator are created by calling Iris.iterator(). See "Finding Nodes in a Global Array"” for more details and examples.

entries()

Iterator.entries() specifies that next().value should be an array containing the node subscript (value(0)) and node value (value(1)). Returns this for chaining.

    entries() → {"intersystems-iris-native".Iterator}

keys()

Iterator.keys() specifies that next().value should contain only the node subscript (key). Returns this for chaining.

    keys() → {"intersystems-iris-native".Iterator}

next()

Iterator.next() positions the iterator at the next sibling node in collation order and returns an object containing done and value properties. If the iterator is at end then done is true, otherwise it is false.

    next() → {any}

When done is false, the return type of the value property can be set by any of the following methods:

  • entries() causes value to return as an array where value(0) is the subscript and value(1) is the node value (this array is the default when the iterator is created).
  • keys() causes value to return only the current subscript.
  • values() causes value to return only the value of the current node.
  • nodes() causes value to return the subnodes of the node as instances of IRISGlobalNode.
  • nodeEntries() causes value to return as an array where value(0) is the subscript and value(1) is the sub-node as instance of IRISGlobalNode (this array is the default when the iterator is created).

nodeEntries()

Iterator.nodeEntries() specifies that next().value should contain both the subscript (key) and sub-node. Returns this for chaining.

    nodeEntries() → {"intersystems-iris-native".Iterator}

nodes()

Iterator.nodes() specifies that next().value should contain only the sub-node. Returns this for chaining.

    nodes() → {"intersystems-iris-native".Iterator}

reversed()

Iterator.reversed() toggles iteration direction between forward and reverse collation order. By default, the iterator is set to forward iteration when it is defined. Returns this for chaining.

    reversed() → {"intersystems-iris-native".Iterator}

startFrom()

Iterator.startFrom() sets the iterator's starting position to the specified subscript. The starting position does not have to be a valid subnode. Returns this for chaining.

    startFrom(subscript) → {"intersystems-iris-native".Iterator}

parameter:

  • subscript — the subscript to use as a starting point. Does not have to specify an existing node.

The iterator will not point to a node until you call next() to advance to the next existing node in collating order.

subscripts()

Iterator.subscripts() specifies that next().value should contain only the node subscript (key). Returns this for chaining. Alias for keys()

    subscripts() → {"intersystems-iris-native".Iterator}

values()

Iterator.values() specifies that next().value should contain only the node value. Returns this for chaining.

    values() → {"intersystems-iris-native".Iterator}

Class IRISGlobalNode

Class IRISGlobalNode is a member of "intersystems-iris-native". Instances of IRISGlobalNode are created by calling Iris.node(). This class provides an iterable interface that behaves like a virtual dictionary representing the immediate children of a global node.

clear()

IRISGlobalNode.clear() completely deletes the IRISGlobalNode from the IRIS server.

    clear()

delete()

IRISGlobalNode.delete() removes the specified value from the IRISGlobalNode object by subscript. Returns true if the subscript existed and has been removed, or false if the subscript does not exist.

    remove(subscript) → {boolean}

parameters:

  • subscript — the subscript to remove from the IRISGlobalNode.

get()

IRISGlobalNode.get() returns a specified value from an IRISGlobalNode object. Returns the value associated with the specified subscript or undefined (or default_value) if the node is UNDEFINED.

    get(subscript, default_value?) → {any}

parameters:

  • subscript — the subscript to return from the IRISGlobalNode belongs.
  • default_value — a value to return if the subscript does not exist (optional).

entries()

IRISGlobalNode.entries() returns an Iterator object of the current IRISGlobalNode which can be iterated over to yield subscript-value pairs. Iterator is an iterable so the for-of loop can be used. When the protocol [Symbol.iterator] is used, it returns a function that, when invoked, returns this iterator itself.

    entries() → {Iterator}

forEach()

IRISGlobalNode.forEach() executes a provided function once per each subscript/value pair in the IRISGlobalNode.

    forEach(callback, thisArg)

parameters:

  • callback — function to execute for each subscript/value pair in the IRISGlobalNode
  • thisArg — value to use as this when executing the callback

has()

IRISGlobalNode.has() returns a boolean indicating whether a value with the specified subscript exists (true) or not (false).

    has(subscript) → {boolean}

parameters:

  • subscript — the subscript to search for in the IRISGlobalNode.

keys()

IRISGlobalNode.keys() returns an Iterator object of the current IRISGlobalNode which can be iterated over to yield only subscripts(keys). Iterator is an iterable so the for-of loop can be used. When the protocol [Symbol.iterator] is used, it returns a function that, when invoked, returns this iterator itself.

    keys() → {Iterator}

nodeEntries()

IRISGlobalNode.nodeEntries() returns an Iterator object of the current IRISGlobalNode which can be iterated over to yield subscript-subnode pairs. Iterator is an iterable so the for-of loop can be used. When the protocol [Symbol.iterator] is used, it returns a function that, when invoked, returns this iterator itself.

    nodeEntries() → {Iterator}

node()

IRISGlobalNode.node() returns an IRISGlobalNode object that represents the subnode at a given subscript.

parameters:

  • subscript — the subscript of the requested subnode.

nodes()

IRISGlobalNode.nodes() returns an Iterator object of the current IRISGlobalNode which can be iterated over to yield only subnodes. Iterator is an iterable so the for-of loop can be used. When the protocol [Symbol.iterator] is used, it returns a function that, when invoked, returns this iterator itself.

    nodes() → {Iterator}

reversed()

IRISGlobalNode.reversed() returns a reverse Iterator object of the current IRISGlobalNode which can be iterated over to yield subscript-value pairs. Iterator is an iterable so the for-of loop can be used. When the protocol [Symbol.iterator] is used, it returns a function that, when invoked, returns this iterator itself.

    reversed() → {Iterator}

set()

IRISGlobalNode.set() adds or updates the value of a specified subscript in the IRISGlobalNode. Returns this for chaining.

    set(subscript, value) → {IRISGlobalNode}

parameters:

  • subscript — the subscript of the value to add in the IRISGlobalNode
  • value — the value to add in the IRISGlobalNode

size()

IRISGlobalNode.size() returns the number of subscript-value pairs in the IRISGlobalNode.

    size() → {number}

subscripts()

IRISGlobalNode.subscripts(), alias for keys(), returns an Iterator object of the current IRISGlobalNode which can be iterated over to yield only subscripts(keys). Iterator is an iterable so the for-of loop can be used. When the protocol [Symbol.iterator] is used, it returns a function that, when invoked, returns this iterator itself.

    subscripts() → {Iterator}

values()

IRISGlobalNode.values() returns an Iterator object of the current IRISGlobalNode which can be iterated over to yield only values. Iterator is an iterable so the for-of loop can be used. When the protocol [Symbol.iterator] is used, it returns a function that, when invoked, returns this iterator itself.

    values() → {Iterator}

Class IRISList

The IRISList class provides an interface to interact with IRIS $LIST data. Instances of IRISList are created by the class constructor

IRISList(list, options)

parameters:

  • list — a list to initialise your list with. Can be IRISList or $LIST formated Buffer (optional)
  • options — an object that describes how elements will be formatted when stored in the list (optional). It is a JavaScript object of this form: {locale: 'utf-16', isUnicode: true, compactDouble: false}, where all properties are optional and if not provided they will automatically default in the values described. locale and isUnicode should be in sync and describe how strings are stored in the list, while compactDouble indicates whether numbers will be compacted when stored.

Note: If you wish for your IRIS server to be able to decode your list properly please make sure to format the list according to the server formatting. You can find your server formatting stored in the properties of your Connection object (see compactDouble and serverLocale).

add()

IRISList.add() adds a data element at the end of the list. Returns this for chaining.

    add(value) → {IRISList}

parameters:

  • value — the value of the list element to be added

clear()

IRISList.clear() clears all data elements from the list. Returns this for chaining.

    clear() → {IRISList}

count()

IRISList.count() returns the number of data elements in the list.

    count() → {number}

equals()

IRISList.equals() compares a list to the current list. Returns true if they are equal and false otherwise.

    equals(otherList) → {boolean}

parameters:

  • otherList — the list to compare the current list to.

get()

IRISList.get() gets the list element at the specified index. If the element value is expected to be a list then use getList instead. Returns the requested element if index valid, else it throws. Returns null if element is an empty string.

    get(index) → {any}

parameters:

  • index — the position of the element to retrieve. Should be >= 1.

getBoolean()

IRISList.getBoolean() gets the list element at the specified index as a boolean. Returns null if element is an empty string.

    getBoolean(index) → {boolean|null}

parameters:

  • index — the position of the element to retrieve. Should be >= 1.

getBuffer()

IRISList.getBuffer() returns a Buffer that contains the $LIST format of all the data elements in the list. Returns null if element is an empty string.

    getBuffer() → {Buffer|null}

getBytes()

IRISList.getBytes() gets the list element at the specified index as a Buffer. Returns null if element is an empty string.

    getBytes(index) → {Buffer|null}

parameters:

  • index — the position of the element to retrieve. Should be >= 1.

getDecimal()

IRISList.getDecimal() gets the list element at the specified index as a Decimal. Returns null if element is an empty string.

    getDecimal(index) → {Decimal|null}

parameters:

  • index — the position of the element to retrieve. Should be >= 1.

getBigInt()

IRISList.getBigInt() gets the list element at the specified index as a bigint number. Returns null if element is an empty string.

    getBigInt(index) → {bigint|null}

parameters:

  • index — the position of the element to retrieve. Should be >= 1.

getList()

IRISList.getList() gets the list element at the specified index as an IRISList. If element not in a list format it will throw. Returns empty list if element is an empty string.

    getList(index) → {IRISList}

parameters:

  • index — the position of the element to retrieve. Should be >= 1.

getIRISList()

IRISList.getIRISList() gets the list element at the specified index as an IRISList. If element not in a list format it will throw. Returns empty list if element is an empty string. Alias of getList.

    getIRISList(index) → {IRISList}

parameters:

  • index — the position of the element to retrieve. Should be >= 1.

getNumber()

IRISList.getNumber() gets the list element at the specified index as a number. Returns null if element is an empty string.

    getNumber(index) → {number|null}

parameters:

  • index — the position of the element to retrieve. Should be >= 1.

getString()

IRISList.getString() gets the list element at the specified index as a string. Returns null if element is an empty string.

    getString(index) → {string|null}

parameters:

  • index — the position of the element to retrieve. Should be >= 1.

remove()

IRISList.remove() removes the list element at the specified index from the list. Returns back this for chaining.

    remove(index) → {IRISList}

parameters:

  • index — the element position to retrieve. Should be >= 1.

set()

IRISList.set() changes the data element at the specified index to a new value. If the index is beyond the length of the IRISList, IRISList will be first expanded to that many elements, padded with null elements. Returns back this for chaining.

    set(index, value) → {IRISList}

parameters:

  • index — the element position to set. Should be >= 1.
  • value — the element value.

size()

IRISList.size() returns the total size (number of bytes) of the list

    size() → {number}

toString()

IRISList.toString() returns a string containing the formatted list value.

    toString() → {string}

Class IRISObject

Class IRISObject is a member of "intersystems-iris-native" and acts as a proxy objects created on behalf of IRIS objects. Instances of this class are automatically created when the IRIS instance returns the object reference of a created object on the server.

close()

IRISObject.close() closes the proxy object.

    close()

get()

IRISObject.get() retrieves the value of a property of the IRISObject object. Returns the value of the property or null if property contains an empty string.

    get(propertyName) → {null|any}

parameters:

  • propertyName — property name

getBoolean()

IRISObject.getBoolean() retrieves the value of a property of the IRISObject object as a boolean. Returns the value of the property converted to boolean or null if the property contains empty string.

    getObject(propertyName) → {null|boolean}

parameters:

  • propertyName — property name

getBytes()

IRISObject.getBytes() retrieves the value of a property of the IRISObject object as a Buffer. Returns the value of the property converted to Buffer or null if the property contains empty string.

    getBuffer(propertyName) → {null|Buffer}

parameters:

  • propertyName — property name

getDecimal()

IRISObject.getDecimal() retrieves the value of a property of the IRISObject object as a Decimal. Returns the value of the property converted to Decimal or null if the property contains empty string.

    getDecimal(propertyName) → {null|Decimal}

parameters:

  • propertyName — property name

getBigInt()

IRISObject.getBigInt() retrieves the value of a property of the IRISObject object as a bigint number. Returns the value of the property converted to a bigint or null if the property contains empty string.

    getBigInt(propertyName) → {null|number}

parameters:

  • propertyName — property name

getNumber()

IRISObject.getNumber() retrieves the value of a property of the IRISObject object as a number. Returns the value of the property converted to number or null if the property contains empty string.

    getNumber(propertyName) → {null|number}

parameters:

  • propertyName — property name

getIRISList()

IRISObject.getIRISList() retrieves the value of a property of the IRISObject object as a list. Returns the value of the property converted to list or null if the property contains empty string.

    getIRISList(propertyName) → {null|IRISList}

parameters:

  • propertyName — property name

getObject()

IRISObject.getObject() retrieves the value of a property of the IRISObject object. Returns the value of the property or null if the contains empty string.

    getObject(propertyName) → {null|any}

parameters:

  • propertyName — property name

getString()

IRISObject.getString() retrieves the value of a property of the IRISObject object as a string. Returns the value of the property converted to string or null if the property contains empty string.

    getString(propertyName) → {null|string}

parameters:

  • propertyName — property name

invoke()

IRISObject.invoke() invokes a method of the IRISObject object that returns a value (null if empty string returned from IRIS)

    invoke(methodName, ...arguments) → {any}

parameters:

  • methodName — name of a method.
  • args — 0 or more method arguments of supported types

invokeBoolean()

IRISObject.invokeBoolean() invokes a method of the IRISObject object that returns a value as a boolean or null if empty string returned from IRIS.

    invokeBoolean(methodName, ...arguments) → {boolean|null}

parameters:

  • methodName — name of a method.
  • args — 0 or more method arguments of supported types

invokeBytes()

IRISObject.invokeBytes() invokes a method of the IRISObject object that returns a value as a Buffer or null if empty string returned from IRIS.

    invokeBuffer(methodName, ...arguments) → {Buffer|null}

parameters:

  • methodName — name of a method.
  • args — 0 or more method arguments of supported types

invokeDecimal()

IRISObject.invokeDecimal() invokes a method of the IRISObject object that returns a value as a Decimal or null if empty string returned from IRIS.

    invokeDecimal(methodName, ...arguments) → {Decimal|null}

parameters:

  • methodName — name of a method.
  • args — 0 or more method arguments of supported types

invokeBigInt()

IRISObject.invokeBigInt() invokes a method of the IRISObject object that returns a value as a bigint or null if empty string returned from IRIS.

    invokeBigInt(methodName, ...arguments) → {bigint|null}

parameters:

  • methodName — name of a method.
  • args — 0 or more method arguments of supported types

invokeIRISList()

IRISObject.invokeIRISList() invokes a method of the IRISObject object that returns a value as an IRISList. If empty string to be returned from IRIS, the list will be empty.

    invokeIRISList(methodName, ...arguments) → {IRISList}

parameters:

  • methodName — name of a method.
  • args — 0 or more method arguments of supported types

invokeNumber()

IRISObject.invokeNumber() invokes a method of the IRISObject object that returns a value as a number or null if empty string returned from IRIS.

    invokeNumber(methodName, ...arguments) → {number|null}

parameters:

  • methodName — name of a method.
  • args — 0 or more method arguments of supported types

invokeObject()

IRISObject.invokeObject() invokes a method of the IRISObject object that returns a value (or null if empty string returned from IRIS)

    invokeObject(methodName, ...arguments) → {any}

parameters:

  • methodName — name of a method.
  • args — 0 or more method arguments of supported types

invokeString()

IRISObject.invokeString() invokes a method of the IRISObject object that returns a value as a string or null if empty string returned from IRIS.

    invokeString(methodName, ...arguments) → {string|null}

parameters:

  • methodName — name of a method.
  • args — 0 or more method arguments of supported types

invokeVoid()

IRISObject.invokeBoolean() invokes a method of the IRISObject object that does not return a value.

    invokeVoid(methodName, ...arguments)

parameters:

  • methodName — name of a method.
  • args — 0 or more method arguments of supported types

set()

IRISObject.set() sets the value of a property of the IRISObject object.

    set(propertyName, propertyValue)

parameters:

  • propertyName — name of a property
  • propertyValue — new value of the property

Class IRISReference

Class IRISReference is used to call method/routine with pass-by-reference arguments. An IRISReference can be created using the class constructor

IRISReference(value, type)

parameters:

  • value — The value to pass by reference
  • type — optional Symbol type hint that describes the type of the value. If set to IRISReference.Type.ANY, InterSystems IRIS assumes the default database type for the value. (default: IRISReference.Type.ANY)

possible values for type are:

  • IRISReference.Type.ANY
  • IRISReference.Type.BOOLEAN
  • IRISReference.Type.BYTES
  • IRISReference.Type.DECIMAL
  • IRISReference.Type.BIGINT
  • IRISReference.Type.NUMBER
  • IRISReference.Type.IRISLIST
  • IRISReference.Type.STRING

getBoolean()

IRISReference.getBoolean() gets the value of the IRISReference object as boolean.

    getBoolean() → {boolean}

getBytes()

IRISReference.getBytes() gets the value of the IRISReference object as Buffer.

    getBytes() → {Buffer}

getDecimal()

IRISReference.getDecimal() gets the value of the IRISReference object as Decimal.

  getDecimal() → {Decimal}

getBigInt()

IRISReference.getBigInt() gets the value of the IRISReference object as a bigint number.

  getBigInt() → {bigint}

getIRISList()

IRISReference.getIRISList() gets the value of the IRISReference object as IRISList.

  getIRISList() → {IRISList}

getNumber()

IRISReference.getNumber() gets the value of the IRISReference object as number.

  getNumber() → {number}

getObject()

IRISReference.getObject() gets the value of the IRISReference object.

  getObject() → {any}

getString()

IRISReference.getString() gets the value of the IRISReference object as string.

  getString() → {string}

getType()

IRISReference.getType() gets the (suggested) type of the value of this IRISReference object.

  getType() → {IRISReference.Type}

getValue()

IRISReference.getValue() gets the value of the IRISReference object.

  getValue() → {any}

setType()

IRISReference.setType() changes the (suggested) type of the value the IRISReference object referes to.

  setValue(type)

parameter:

  • type — the new (suggested) type of the value we want to pass by reference

setValue()

IRISReference.setValue() sets the value the IRISReference object referes to.

  setValue(value) → {any}

parameter:

  • value — the value we want to pass by reference

toString()

IRISReference.toString() returns the string representation of the IRISReference object.

  toString() → {string}
Warning:

On older InterSystems database platforms, code consisted of modules containing functions and procedures, rather than object-oriented classes and methods (see “Legacy Forms of Subroutines” in Using ObjectScript). Functions are frequently necessary for older code bases, but new code should use object oriented method calls if possible. In fact newer (2024.1+) IRIS Server versions will throw an error for Iris.function(Type) or Iris.procedure calls. See: %Service_Bindings in Managing Services documentation
.

Calling ObjectScript Methods and Functions

Quick Start