Pesquisar

Artigo
· Jul. 28 5min de leitura

Introducing typeorm-iris: TypeORM for InterSystems IRIS from Node.js

Overview

The typeorm-iris project provides experimental support for integrating TypeORM with InterSystems IRIS, enabling developers to interact with IRIS using TypeORM’s well-known decorators and repository abstractions. This allows a more familiar development experience for JavaScript and TypeScript developers building Node.js applications with IRIS as the backend database.

TypeORM MongoDB Review. I recently started using TypeORM in a… | by Eliezer  Steinbock | Medium

While the project implements key integration points with TypeORM and supports basic entity operations, it’s not yet battle-tested or suitable for production environments.

Why typeorm-iris?

The official InterSystems IRIS Node.js driver does not provide native SQL query execution in the way that other database drivers (e.g., for PostgreSQL or MySQL) do. Instead, you must use an ObjectScript-based API (e.g., %SQL.Statement) to prepare and execute SQL commands.

This becomes problematic when building modern applications that rely on Object-Relational Mapping (ORM) tools like TypeORM. TypeORM expects a lower-level driver capable of preparing and executing raw SQL in a single connection session, which is not currently available with IRIS’s JavaScript tooling.

To overcome these limitations, typeorm-iris implements the necessary pieces to bridge IRIS and TypeORM, using the available ObjectScript SQL execution interfaces under the hood.

Early Stage & Known Issues

This project is in its initial phase and has only been tested with a limited number of cases. Expect instability, missing features, and breaking changes in future iterations.

Notable limitations observed during development include:

1. Excessive Network Roundtrips

Executing SQL through the %SQL.Statement class from JavaScript involves multiple network messages between the Node.js process and the IRIS server. For example, a single logical SQL operation may require multiple steps like:

  • Preparing the statement
  • Executing the query
  • Fetching metadata
  • Fetching rows individually

Each of these can result in separate messages over the network, resulting in significantly more overhead compared to using a native SQL driver.

2. No True Async/Parallel Support

The official IRIS Node.js driver does not support asynchronous usage in a multithreaded or worker-based context:

  • Reconnecting in the same process often fails or causes unpredictable behavior.
  • Spawning worker threads and using the driver inside them leads to issues.
  • Only one connection per process works reliably.

These constraints make it unsuitable for modern concurrent Node.js applications. In practice, this limits how well the driver can scale with concurrent workloads, and it significantly restricts architectural choices.

Usage Guide

Due to usage of latest IRIS SQL Fatures requires IRIS 2025.1+ to work.

You can install typeorm-iris via npm:

npm install typeorm-iris

Because this driver is not officially supported by TypeORM, using it requires a workaround for setting up the DataSource. You cannot directly use new DataSource() or createConnection() as you would with official drivers.

Custom DataSource Setup

import { IRISDataSource, IRISConnectionOptions } from "typeorm-iris"

const dataSourceOptions: IRISConnectionOptions = {
    name: "iris",
    type: "iris",
    host: "localhost",
    port: 1972,
    username: "_SYSTEM",
    password: "SYS",
    namespace: "USER",
    logging: true,
    dropSchema: true,
}

export function createDataSource(options: any): IRISDataSource {
    // @ts-ignore
    const dataSource = new IRISDataSource({ ...dataSourceOptions, ...options })
    return dataSource
}

Once initialized, you can use TypeORM decorators as usual:

import { Entity, PrimaryGeneratedColumn, Column } from "typeorm"

@Entity()
export class User {
    @PrimaryGeneratedColumn()
    id: number

    @Column()
    name: string

    @Column()
    email: string
}

Using repositories works similarly:

const userRepository = dataSource.getRepository(User)
const newUser = userRepository.create({ name: "Alice", email: "alice@example.com" })
await userRepository.save(newUser)

Sample Projects

The GitHub repository includes a sample/ folder with several fully working examples:

  • sample1-simple-entity
  • sample2-one-to-one
  • sample3-many-to-one
  • sample4-many-to-many
  • sample16-indexes

These cover basic persistence, relationships, and schema features, offering practical usage demonstrations.

Unit Tests

Initial testing includes the following use cases:

Entity Model

  • should save successfully and use static methods successfully
  • should reload given entity successfully
  • should reload exactly the same entity
  • should upsert successfully

Entity Schema > Indices

  • basic

Persistence

  • basic functionality
  • entity updation
  • insert > update-relation-columns-after-insertion
  • many-to-many
  • one-to-one

These tests are limited in scope and more coverage will be added as the project matures.

Supported Features

  • Entity decorators: @Entity(), @Column(), @PrimaryGeneratedColumn()
  • Repositories: create, save, find, delete, etc.
  • Schema drop and sync (experimental)
  • Partial support for relations and custom queries

Again, these features are early-stage and may not cover the full range of TypeORM’s capabilities.

Real-World Constraints

InterSystems IRIS Node.js Driver Limitations

  • Only one usable connection per process
  • No proper support for parallel operations or threading
  • Lack of native SQL API support (via SQL protocol)
  • Heavy reliance on message-based communication using proprietary protocol

Until InterSystems updates the official driver with support for proper SQL execution and concurrent operations, this project will be fundamentally limited in terms of performance and scalability.

Feedback & Contribution

As this is an experimental driver, your feedback is crucial. Whether you're trying it out for a small side project or evaluating it for broader use, please share issues and suggestions on GitHub:

➡️ github.com/caretdev/typeorm-iris/issues

Pull requests, test cases, and documentation improvements are welcome.

What's Next

Planned future improvements include:

  • Expanding test coverage for real-world queries and schema designs
  • Handling more TypeORM query builder features
  • Investigating batching optimizations
  • Improving schema introspection for migrations

Conclusion

typeorm-iris brings much-needed TypeORM support to InterSystems IRIS for Node.js developers. While it’s not production-ready today and inherits severe limitations from the current driver infrastructure, it provides a foundation for further experimentation and potentially wider adoption in the IRIS developer community.

If you're an IRIS developer looking to integrate with a modern Node.js backend using TypeORM, this is the starting point.

And if you found this useful, please vote for it in the InterSystems Developer Tools Contest!

10 Comments
Discussão (10)3
Entre ou crie uma conta para continuar
Resumo
· Jul. 28
Artigo
· Jul. 27 3min de leitura

JDBCログの取得方法

これは InterSystems FAQ サイトの記事です。
 

JDBCクライアントからのアクセスでエラーが発生した場合、返ってきたエラーメッセージやコンソールログ上の情報だけでは原因がよくわからない場合があります。

そのような場合にJDBCドライバのクライアントログを取得することで、エラーについての詳細情報を取得することができます。

JDBCログの取得方法については以下をご参照ください。

JDBCのログ

ログを指定する際に、ディレクトリ名を含まずに直接ファイル名を指定した場合、そのアプリケーションのディレクトリにその指定したファイル名でログが出力されます。

ODBCログの様にPID毎に取得する方法は用意されていません。

JDBCログが正常に取得できている場合、以下の様な内容が書き込まれます。

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
	Started At:     2025/03/27 11:52:16
	Driver Name:    com.intersystems.jdbc.IRISDriver
	Jar File Name:  intersystems-jdbc-3.9.0.jar
	Client Version: 3.9.0.0
	Compiled At:    3 June, 2024 at 07:34PM UTC
	JDBC Version:   4.2
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Sent: (03/27/25-11:52:16:156) [ThreadID = 1 ] [JobNumber = -1 ] [DeviceID = 1212899836 ]
Header:
  0000:  02  00  00  00  01  00  00  00  00  00  00  00  48  53      ............HS
Message:
  0000:  43  00                                                      C.


Received: (03/27/25-11:52:16:199) [ThreadID = 1 ] [JobNumber = -1 ] [DeviceID = 1212899836 ]
Header:
  0000:  0D  00  00  00  01  00  00  00  00  00  00  00  00  00      ..............
Message:
  0000:  43  00  01  00  09  01  55  6E  69  63  6F  64  65          C.....Unicode


Sent: (03/27/25-11:52:16:199) [ThreadID = 1 ] [JobNumber = -1 ] [DeviceID = 1212899836 ]
Header:
  0000:  C5  00  00  00  03  00  00  00  00  00  00  00  43  4E      ............CN
Message:
  0000:  06  01  55  53  45  52  09  01  59  78  BA  FA  5C  3B      ..USER..Yx..\;
  000E:  DF  05  01  9E  FF  DE  0A  01  68  73  61  74  6F  63      ........hsatoc
  001C:  74  72  1C  01  6A  70  37  33  32  30  6E  6F  6E  6F      tr..jp7320nono
  002A:  2E  69  73  63  69  6E  74  65  72  6E  61  6C  2E  63      .iscinternal.c
  0038:  6F  6D  05  01  41  70  70  6F  01  06  01  4A  44  42      om..Appo...JDB
  0046:  43  1D  01  69  6E  74  65  72  73  79  73  74  65  6D      C..InterSystems
  0054:  73  2D  6A  64  62  63  2D  33  2E  39  2E  30  2E  6A      s-jdbc-3.9.0.j
  0062:  61  72  09  01  33  2E  39  2E  30  2E  30  11  01  4D      ar..3.9.0.0..M
  0070:  61  63  20  4F  53  20  58  5C  31  35  2E  33  2E  32      ac OS X\15.3.2
  007E:  30  01  4A  61  76  61  20  48  6F  74  53  70  6F  74      0.Java HotSpot
  008C:  28  54  4D  29  20  36  34  2D  42  69  74  20  53  65      (TM) 64-Bit Se
  009A:  72  76  65  72  20  56  4D  5C  32  33  2E  30  2E  31      rver VM\23.0.1
  00A8:  2B  31  31  2D  33  39  0B  01  53  48  4D  7C  7C  7C      +11-39..SHM|||
  00B6:  7C  7C  31  03  01  00  03  04  01  03  04  01  03  04      ||1...........
  00C4:  3B                                                          ;


ログの内容の解析は専門的な知識が必要となりますので、取得後インターシステムズサポートセンターまでお送りください。

Discussão (0)1
Entre ou crie uma conta para continuar
Artigo
· Jul. 27 4min de leitura

ODBCログの取得方法(UNIX)

これは InterSystems FAQ サイトの記事です。
 

ODBCクライアントからのアクセスでエラーが発生した場合、返ってきたエラーメッセージやコンソールログ上の情報だけでは原因がよくわからない場合があります。

そのような場合にODBCドライバのクライアントログを有効にすることで、エラーについての詳細情報を取得することができます。

ODBCログの有効化については以下をご参照ください。

ODBCログの有効化

UNIX系のシステムの場合、上記に記載されている通り、2種類のログが取得できます。 

  • クライアント・ドライバ・ログの取得方法 以下の環境変数でトレースのオンと出力するファイルを指定します。
export IRISODBCTRACE=1
export IRISODBCTRACEFILE=/Users/user1/work/odbcclient.log
  •  ドライバマネージャのログの取得方法 ドライバマネージャのデータソース設定ファイル(ODBC.ini)に以下の様にトレースをオンにする設定とログファイルの場所と名前を指定します。

  

[ODBC Data Sources]
IRIS ODBC User = IRIS iODBC Driver

[IRIS ODBC User]
Driver      = /opt/iris/bin/libirisodbc35.so
Description = 
Host        = localhost
Namespace   = USER
UID         = _system
Password	= SYS
Protocol    = TCP
Port        = 1972
Trace		= on
TraceFile   = /Users/user1/work/iodbctrace.log

変更の反映にはODBCクライアントアプリケーションを再起動する必要があります。

クライアントのプロセス毎に個別にログを取得すつこともできます。 クライアントログが正常に取得できている場合、以下の様な内容が書き込まれます。

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
	Started At: Thu Mar 27 11:02:27 2025

	Driver Name:	libirisodbc35.so
	Unicode Client Version:	2024.2.0.247.0
	Compiled at:	Jul 16 2024 09:26:07
	ODBC Version:	03.51
	Locale Setting:	ja_JP.UTF-8
	ODBC Config file:	/Library/ODBC/odbc.ini
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Warning: IRISConnect Failed to load, Error Code: 2; Reason=dlopen(irisconnect.so, 0x0002): tried: 'irisconnect.so' (relative path not allowed in hardened program), '/System/Volumes/Preboot/Cryptexes/OSirisconnect.so' (no such file), '/usr/lib/irisconnect.so' (no such file, not in dyld cache), 'irisconnect.so' (relative path not allowed in hardened program), '/usr/lib/irisconnect.so' (no such file, not in dyld cache)
--> SQLAllocHandle: (03/27/25-11:02:27:224) htype = 1, inhandle = 00000000
    --> SQLAllocEnv: (03/27/25-11:02:27:224) 
    <-- SQLAllocEnv: (03/27/25-11:02:27:224) henv = 0x1301b8000 returning 0
<-- SQLAllocHandle: (03/27/25-11:02:27:224) Returning 0, outhandle = 0x1301b8000


--> SQLSetEnvAttr: (03/27/25-11:02:27:224) henv = 0x1301b8000, Attribute=200, Value=3, StringLength=0
<-- SQLSetEnvAttr: (03/27/25-11:02:27:224) Returning 0

--> SQLAllocHandle: (03/27/25-11:02:27:224) htype = 2, inhandle = 0x1301b8000
    --> SQLAllocConnect: (03/27/25-11:02:27:224) henv = 0x1301b8000
    <-- SQLAllocConnect: (03/27/25-11:02:27:224) hdbc = 0x1300f0000 returning 0
<-- SQLAllocHandle: (03/27/25-11:02:27:224) Returning 0, outhandle = 0x1300f0000

ドライバマネージャログが正常に取得できている場合、以下の様な内容が書き込まれます。

** iODBC Trace file
** Trace started on Thu Mar 27 11:02:27 2025
** Driver Manager: 03.52.0607.1008


[000000.024585]
soffice         205384840 EXIT  SQLDriverConnect with return code 0 (SQL_SUCCESS)
		SQLHDBC           0x600002d4cf00
		SQLPOINTER        0x0
		SQLCHAR         * 0x6000017c51a8
		SQLSMALLINT       19
		SQLCHAR         * 0x16d9f9e58
				  | DSN=IRIS ODBC User;SERVER=localhost;PORT |
				  | =1972;DATABASE=USER;AUTHENTICATION METHO |
				  | D=0;UID=_system;PWD=***;STATIC CURSORS=0 |
				  | ;QUERY TIMEOUT=1                         |
		SQLSMALLINT       4095
		SQLSMALLINT     * 0x16d9f9e3e (136)
		SQLUSMALLINT      0 (SQL_DRIVER_NOPROMPT)

[000000.024666]
soffice         205384840 ENTER SQLGetInfo
		SQLHDBC           0x600002d4cf00
		SQLUSMALLINT      25 (SQL_DATA_SOURCE_READ_ONLY)
		SQLPOINTER        0x16d9f95d8
		SQLSMALLINT       511
		SQLSMALLINT     * 0x16d9f95d6

ログの内容の解析は専門的な知識が必要となりますので、取得後インターシステムズサポートセンターまでお送りください。

Discussão (0)1
Entre ou crie uma conta para continuar