Registry / database / typeorm-postgres-naming-strategies

typeorm-postgres-naming-strategies

JSON →
library3.0.2jsnpmunverified

Strict snake_case naming strategy for TypeORM targeting PostgreSQL. Current stable version 3.0.2, released as needed. Automatically converts camelCase entity property names (e.g., createdAt) to snake_case database columns (created_at) in tables, relations, and indexes. Lightweight — only one strategy class (PostgresNamingStrategy). Unlike generic naming strategy packages, it adheres strictly to PostgreSQL naming conventions and is tested against TypeORM 0.2 and 0.3. Ships TypeScript definitions and supports both ESM and CJS.

npm install typeorm-postgres-naming-strategies
INSTALL
IMPORT
SIG · TYPEORM-POSTGRES-N
T
typeorm-postgres-naming-strategies
databasejavascriptv3.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PostgresNamingStrategy
import { PostgresNamingStrategy } from 'typeorm-postgres-naming-strategies'
const PostgresNamingStrategy = require('typeorm-postgres-naming-strategies')
Use named import. CJS require works, but mistakenly doing require('typeorm-postgres-naming-strategies').default is wrong.
PostgresNamingStrategy
import { PostgresNamingStrategy } from 'typeorm-postgres-naming-strategies'; const strategy = new PostgresNamingStrategy()
import PostgresNamingStrategy from 'typeorm-postgres-naming-strategies'
Default export does not exist; must use named import.
PostgresNamingStrategy type
import type { PostgresNamingStrategy } from 'typeorm-postgres-naming-strategies'
import { PostgresNamingStrategy } from 'typeorm-postgres-naming-strategies' // only for type usage
When using only as a type, prefer type-only import to avoid bundling.

Connect to PostgreSQL with snake_case naming strategy applied automatically to all entities.

import { createConnection } from 'typeorm'; import { PostgresNamingStrategy } from 'typeorm-postgres-naming-strategies'; await createConnection({ type: 'postgres', host: process.env.DB_HOST ?? 'localhost', port: parseInt(process.env.DB_PORT ?? '5432'), username: process.env.DB_USER ?? 'postgres', password: process.env.DB_PASSWORD ?? '', database: process.env.DB_NAME ?? 'test', entities: [__dirname + '/entities/*.ts'], namingStrategy: new PostgresNamingStrategy(), });
Debug
Known issues
gotchaNamingStrategy applies only when synchronize: true or migrations are used. Without synchronization, column names must match manually.
fix
Ensure synchronize: true in TypeORM config or run migrations after defining entities.
affects: >=0.0.0
deprecatedCJS require() pattern using .default is incorrect — the package exports no default. Use named import.
fix
Use require('typeorm-postgres-naming-strategies').PostgresNamingStrategy
affects: >=1.0.0
gotchaStrategy only handles snake_case. Mixed cases in foreign key column names may not be transformed as expected.
fix
Manually override column names using @Column({ name: 'explicit_name' }) if needed.
affects: >=0.0.0
breakingVersion 2.x drops support for TypeORM <0.3 and changes class name from SnakeNamingStrategy to PostgresNamingStrategy.
fix
Update import to { PostgresNamingStrategy } and ensure TypeORM >=0.3.
affects: >=2.0.0 <3.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'namingStrategy')
Strategy not instantiated — passed class instead of instance.
fix
Use namingStrategy: new PostgresNamingStrategy() instead of namingStrategy: PostgresNamingStrategy
Module '"typeorm-postgres-naming-strategies"' has no exported member 'SnakeNamingStrategy'.
Class was renamed in v2.0.0 to PostgresNamingStrategy.
fix
Use { PostgresNamingStrategy } from 'typeorm-postgres-naming-strategies'.
Cannot find module 'typeorm-postgres-naming-strategies' or its corresponding type declarations.
Missing installation or TypeScript node resolution issue.
fix
Run npm install typeorm-postgres-naming-strategies and ensure tsconfig.json includes 'node_modules' in typeRoots.
Upgrade
Version history
3.0.2latest on npm
Audit
Dependencies
typeormrequiredPeer dependency required to use the naming strategy class
Agent activity
21 hits · last 30 days
node
18
Meta
2
OpenAI (training)
1
Resources
typeorm-postgres-naming-strategies — npm install typeorm-postgres-naming-strategies · libregistry