Initial Release
A TypeORM driver for InterSystems IRIS database, providing seamless integration between TypeORM and IRIS databases.
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.
npm install typeorm-iris
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
}
import { Column, Entity } from "typeorm" import { PrimaryColumn } from "typeorm" import { Generated } from "typeorm"
@Entity("sample01_post")
export class Post {
@PrimaryColumn()
@Generated()
id: number@Column() title: string @Column() text: string @Column({ nullable: false }) likesCount: number
}
import "reflect-metadata" import { Post } from "./entity/Post" import { createDataSource } from "../datasource"
async function main() {
const dataSource = createDataSource({
logging: true,
synchronize: true,
entities: [Post as any],
})try { await dataSource.initialize() } catch (error) { console.log("Cannot connect: ", error) return } const post = new Post() post.text = "Hello how are you?" post.title = "hello" post.likesCount = 100 const postRepository = dataSource.getRepository(Post) try { await postRepository.save(post) console.log("Post has been saved: ", post) } catch (error) { console.log("Cannot save. Error: ", error) } await dataSource.destroy()
}
void main()
interface IRISConnectionOptions {
type: "iris"
host?: string
port?: number
username?: string
password?: string
namespace?: string
sharedmemory?: boolean // Default: false (required for 2025.2+)
poolSize?: number // Default: 5
connectTimeout?: number // Default: 10 seconds
entities?: EntitySchema[] // Entity definitions
synchronize?: boolean // Auto-create tables
logging?: boolean // Enable query logging
}
The driver includes built-in connection pooling to prevent memory leaks:
import { IRISConnectionPool } from "typeorm-iris"
const pool = new IRISConnectionPool(
{
host: "localhost",
port: 1972,
ns: "USER",
user: "_SYSTEM",
pwd: "SYS",
sharedmemory: false,
},
5,
) // Max 5 connections// Get connection from pool
const connection = await pool.getConnection()try {
// Use connection
const iris = connection.createIris()
// ... database operations
} finally {
// Always release connection back to pool
pool.releaseConnection(connection)
}
// Clean shutdown
await pool.closeAll()
The repository includes several example files:
sample/
- TypeORM entity examplesThe driver supports all standard SQL data types plus IRIS-specific types:
TypeORM Type | IRIS Type | Notes |
---|---|---|
integer |
INTEGER |
Auto-increment supported |
varchar |
VARCHAR |
Default length: 255 |
text |
TEXT |
Large text fields |
datetime |
DATETIME |
Timestamps |
boolean |
BIT |
True/false values |
decimal |
DECIMAL |
Precision and scale |
uniqueidentifier |
UUID |
GUID support |
npm run build
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
npm run typecheck
# 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
MIT License - see LICENSE file for details.