{"id":16694,"library":"typeorm-dm","title":"TypeORM Dmdb Dialect","description":"typeorm-dm is a database dialect package that enables TypeORM to connect and interact with Dameng (DMDB) databases. It acts as an adapter layer between TypeORM and the `dmdb` npm package, which is the official Node.js driver for Dameng. The current stable version is 1.0.43524. The project appears to have a fairly active release cadence, with multiple updates in 2024 and 2025, often driven by changes in the underlying `dmdb` driver. A key differentiator is its explicit requirement to use `DmdbDataSource` rather than relying on TypeORM's automatic driver loading, and its handling of features like `simple-enum` columns by converting them to `varchar` with check constraints. It specifically dropped runtime dependency on `oracledb` in v1.0.26038, highlighting its focus solely on Dameng.","status":"active","version":"1.0.43524","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install typeorm-dm","lang":"bash","label":"npm"},{"cmd":"yarn add typeorm-dm","lang":"bash","label":"yarn"},{"cmd":"pnpm add typeorm-dm","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency, this package provides a dialect for TypeORM.","package":"typeorm","optional":false},{"reason":"Runtime dependency, the underlying Dameng database driver.","package":"dmdb","optional":false}],"imports":[{"note":"Primarily designed for ESM usage, as indicated by TypeScript examples. CommonJS usage is possible but less common.","wrong":"const DmdbDataSource = require('typeorm-dm').DmdbDataSource","symbol":"DmdbDataSource","correct":"import { DmdbDataSource } from 'typeorm-dm'"},{"note":"While `DmdbDataSource` is imported from `typeorm-dm`, the configuration object adheres to TypeORM's `DataSourceOptions` interface, with specific `type` and `innerType` fields.","symbol":"DataSourceOptions for Dm","correct":"import { DataSourceOptions } from 'typeorm'; const config: DataSourceOptions = { type: 'oracle', innerType: 'dmdb', ... }"},{"note":"A required polyfill for TypeORM's entity decorators to function correctly. This import should be at the very top of your application entry file.","symbol":"reflect-metadata","correct":"import 'reflect-metadata'"}],"quickstart":{"code":"import \"reflect-metadata\";\nimport { DmdbDataSource } from \"typeorm-dm\";\nimport { Entity, PrimaryGeneratedColumn, Column } from \"typeorm\";\n\n@Entity()\nexport class Photo {\n    @PrimaryGeneratedColumn()\n    id: number;\n\n    @Column()\n    name: string;\n\n    @Column('text')\n    description: string;\n\n    @Column()\n    filename: string;\n\n    @Column()\n    views: number;\n\n    @Column()\n    isPublished: boolean;\n}\n\n// Ensure Dameng is running and accessible, e.g., via Docker or a local installation.\n// Replace connection details with your actual Dameng server information.\nconst AppDataSource = new DmdbDataSource({\n    type: \"oracle\", // TypeORM's internal type for Oracle/DMDB compatibility\n    innerType: \"dmdb\", // Specific inner type for Dameng\n    url: process.env.DM_DATABASE_URL ?? \"dm://SYSDBA:SYSDBA@localhost:5236?schema=SYSDBA\", // Recommended to use URL\n    host: \"localhost\",\n    port: 5236,\n    username: process.env.DM_USERNAME ?? \"SYSDBA\",\n    password: process.env.DM_PASSWORD ?? \"SYSDBA\",\n    schema: process.env.DM_SCHEMA ?? \"SYSDBA\",\n    entities: [Photo],\n    synchronize: true,\n    logging: false,\n});\n\nAppDataSource.initialize()\n    .then(async () => {\n        console.log(\"Data Source has been initialized!\");\n\n        const photoRepository = AppDataSource.getRepository(Photo);\n\n        const newPhoto = new Photo();\n        newPhoto.name = \"My First Photo\";\n        newPhoto.description = \"Just a test photo\";\n        newPhoto.filename = \"photo.jpg\";\n        newPhoto.views = 1;\n        newPhoto.isPublished = true;\n\n        await photoRepository.save(newPhoto);\n        console.log(\"Photo saved successfully.\");\n\n        const allPhotos = await photoRepository.find();\n        console.log(\"All photos:\", allPhotos);\n\n        await AppDataSource.destroy();\n        console.log(\"Data Source has been destroyed!\");\n    })\n    .catch((error) => console.error(\"Error during Data Source initialization:\", error));\n","lang":"typescript","description":"This quickstart demonstrates how to initialize `DmdbDataSource`, define a TypeORM entity, save a new record, and retrieve all records from a Dameng database."},"warnings":[{"fix":"Ensure you are using `typeorm-dm` version 1.0.43524 or newer with the corresponding compatible `dmdb` version to avoid binding issues.","message":"The underlying `dmdb` driver's parameter binding strategy changed, requiring a synchronous update to `typeorm-dm`.","severity":"breaking","affected_versions":">=1.0.43524"},{"fix":"Upgrade to `typeorm-dm` version 1.0.34946 or later. Review your transaction management if explicit `dmdb` driver options were previously used.","message":"The `dmdb` driver's auto-commit configuration policy changed, necessitating updates in `typeorm-dm`.","severity":"breaking","affected_versions":">=1.0.34946"},{"fix":"Be aware of this conversion when inspecting your database schema or migrating between database types. Ensure your enum values conform to the `varchar` length limits and the `CHECK` constraint.","message":"The package specifically handles `enum` and `simple-enum` column types by converting them to `varchar` with `CHECK` constraints in the database. This differs from native enum support in some other database systems.","severity":"gotcha","affected_versions":">=1.0.25820"},{"fix":"Always import and instantiate `DmdbDataSource` directly: `import { DmdbDataSource } from \"typeorm-dm\"; const AppDataSource = new DmdbDataSource({ ... });`","message":"Unlike TypeORM's automatic driver loading based on the `type` field, `DmdbDataSource` must be explicitly imported and used. Setting `type: \"dmdb\"` in a standard `DataSource` config will not work.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Upgrade to `typeorm-dm` version 1.0.25580 or newer to fix potential issues with mixed parameter placeholder styles.","message":"Older versions might have issues with mixed `?` and `:` parameter placeholders in queries.","severity":"gotcha","affected_versions":"<1.0.25580"},{"fix":"If you were implicitly relying on `typeorm-dm` to provide `oracledb` functionality, note that this is no longer the case. `typeorm-dm` is now exclusively for Dameng databases and does not support Oracle connections.","message":"Runtime dependency on the `oracledb` module was removed.","severity":"deprecated","affected_versions":"<1.0.26038"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Import `DmdbDataSource` directly and instantiate it: `import { DmdbDataSource } from 'typeorm-dm'; const AppDataSource = new DmdbDataSource({ /* ... */ });`","cause":"Attempting to use `new DataSource(...)` with `type: 'dmdb'` instead of explicitly importing `DmdbDataSource`.","error":"TypeError: Cannot read properties of undefined (reading 'initialize')"},{"fix":"When using `DmdbDataSource`, set `type: \"oracle\"` and `innerType: \"dmdb\"` in your configuration object. The `type` field uses TypeORM's internal `oracle` driver compatibility layer.","cause":"TypeORM's core `DataSource` does not natively recognize `dmdb` as a `type` option.","error":"Error: \"dmdb\" is not a valid database type. Please specify one of the following: \"mysql\", \"mariadb\", \"postgres\", \"sqlite\", \"oracle\", \"mssql\", \"sap\", \"cockroachdb\", \"cordova\", \"react-native\", \"nativescript\", \"sqljs\", \"mongodb\", \"aurora-data-api\", \"aurora-data-api-pg\", \"expo\", \"capacitor\", \"spanner\"."}],"ecosystem":"npm"}