Skip to content

Repository files navigation

TypeORM-IRIS

A TypeORM driver for InterSystems IRIS database, providing seamless integration between TypeORM and IRIS databases.

Overview

This driver enables you to use TypeORM with InterSystems IRIS databases, supporting both traditional SQL operations and IRIS-specific features. It includes connection pooling for high-performance applications.

Installation

npm install typeorm-iris

Quick Start

Basic Connection

import{IRISDataSource,IRISConnectionOptions}from"typeorm-iris"constdataSourceOptions: IRISConnectionOptions={name: "iris",type: "iris",host: "localhost",port: 1972,username: "_SYSTEM",password: "SYS",namespace: "USER",logging: true,dropSchema: true,}exportfunctioncreateDataSource(options: any): IRISDataSource{// @ts-ignoreconstdataSource=newIRISDataSource({ ...dataSourceOptions, ...options})returndataSource}

Entity Definition

import{Column,Entity}from"typeorm"import{PrimaryColumn}from"typeorm"import{Generated}from"typeorm"
@Entity("sample01_post")exportclassPost{
@PrimaryColumn()
@Generated()id: number
@Column()title: string
@Column()text: string
@Column({nullable: false})likesCount: number}

Basic Operations

import"reflect-metadata"import{Post}from"./entity/Post"import{createDataSource}from"../datasource"asyncfunctionmain(){constdataSource=createDataSource({logging: true,synchronize: true,entities: [Postasany],})try{awaitdataSource.initialize()}catch(error){console.log("Cannot connect: ",error)return}constpost=newPost()post.text="Hello how are you?"post.title="hello"post.likesCount=100constpostRepository=dataSource.getRepository(Post)try{awaitpostRepository.save(post)console.log("Post has been saved: ",post)}catch(error){console.log("Cannot save. Error: ",error)}awaitdataSource.destroy()}voidmain()

Configuration Options

interfaceIRISConnectionOptions{type: "iris"host?: stringport?: numberusername?: stringpassword?: stringnamespace?: stringsharedmemory?: boolean// Default: false (required for 2025.2+)poolSize?: number// Default: 5connectTimeout?: number// Default: 10 secondsentities?: EntitySchema[]// Entity definitionssynchronize?: boolean// Auto-create tableslogging?: boolean// Enable query logging}

Connection Pooling

The driver includes built-in connection pooling to prevent memory leaks:

import{IRISConnectionPool}from"typeorm-iris"constpool=newIRISConnectionPool({host: "localhost",port: 1972,ns: "USER",user: "_SYSTEM",pwd: "SYS",sharedmemory: false,},5,)// Max 5 connections// Get connection from poolconstconnection=awaitpool.getConnection()try{// Use connectionconstiris=connection.createIris()// ... database operations}finally{// Always release connection back to poolpool.releaseConnection(connection)}// Clean shutdownawaitpool.closeAll()

Examples

The repository includes several example files:

  • sample/ - TypeORM entity examples

Supported Data Types

The driver supports all standard SQL data types plus IRIS-specific types:

TypeORM TypeIRIS TypeNotes
integerINTEGERAuto-increment supported
varcharVARCHARDefault length: 255
textTEXTLarge text fields
datetimeDATETIMETimestamps
booleanBITTrue/false values
decimalDECIMALPrecision and scale
uniqueidentifierUUIDGUID support

Development

Building the Project

npm run build

Running Tests

Start IRIS

docker compose up -d iris
npm test

Optionally tests can run with testcontainers, image needs to be passed as envionment variable

export IRIS_IMAGE=containers.intersystems.com/intersystems/iris-community:latest-preview

Type Checking

npm run typecheck

Running Examples

# Basic demo
node build/compiled/sample1-simple-entity/app.js
node build/compiled/sample2-one-to-one/app.js
node build/compiled/sample3-many-to-one/app.js
node build/compiled/sample4-many-to-many/app.js
node build/compiled/sample16-indexes/app.js

Requirements

  • Node.js 20+
  • InterSystems IRIS 2025.1+
  • TypeORM 0.3+

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Support

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages