Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

typeorm-naming-strategy

chantouchsek3.8kMIT2.0.13TypeScript support: included

Custom naming strategies for typeorm

typeorm, naming, strategy, node, orm, naming strategy, snake strategy, typeorm snake, naming strategies

readme

Typeorm naming strategy

ci Latest Version on NPM Software License npm npm

This package provides a few (one, at the moment) useful custom naming strategies. It alliterates the name of columns, relations, and other fields in the database.

For example, using the snake strategy, if you have a model like this:

class User {
  @Column()
  createdAt
}

In the DB the createdAt field will be created_at

Naming strategies available

  • Snake

Installation

It's available as an npm package

npm install typeorm-naming-strategy --save

Or using yarn

yarn add typeorm-naming-strategy

Usage

import { createConnection } from 'typeorm'
// import { SnakeNamingStrategy } from 'typeorm-naming-strategy';
import SnakeNamingStrategy from 'typeorm-naming-strategy'

createConnection({
  // ...
  namingStrategy: new SnakeNamingStrategy(), // Here you'r using the strategy!
})

Alternatively you can use it in combination with a ormconfig.js

// Use require instead of import
// const SnakeNamingStrategy = require("typeorm-naming-strategy").SnakeNamingStrategy
const SnakeNamingStrategy = require('typeorm-naming-strategy')

module.exports = {
  // ...
  namingStrategy: new SnakeNamingStrategy(),
}

Or you can use it in combination with a ormconfig.ts

import SnakeNamingStrategy from 'typeorm-naming-strategy'

module.exports = {
  // ...
  namingStrategy: new SnakeNamingStrategy(),
}

Use with NestJs configuration

import type { MysqlConnectionOptions } from 'typeorm/driver/mysql/MysqlConnectionOptions'
import { registerAs } from '@nestjs/config'
import { SnakeNamingStrategy } from 'typeorm-naming-strategy'

export default registerAs('database', (): MysqlConnectionOptions => ({
  // ...
  namingStrategy: new SnakeNamingStrategy(),
  // ...
}))

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

2.0.13 (2025-04-08)

Bug Fixes

  • deps: bump actions/setup-node from 4.1.0 to 4.3.0 (ff7ad0c)
  • deps: bump actions/stale from 9.0.0 to 9.1.0 (f63cb67)

2.0.12 (2024-12-10)

2.0.11 (2024-11-25)

Bug Fixes

  • deps: bump actions/checkout from 4.1.7 to 4.2.0 (c1616d9)
  • deps: bump actions/checkout from 4.2.0 to 4.2.1 (0cfeb30)
  • deps: bump actions/checkout from 4.2.1 to 4.2.2 (bc89b34)
  • deps: bump actions/setup-node from 4.0.4 to 4.1.0 (a7c4219)

2.0.10 (2024-09-20)

Bug Fixes

  • deps: bump actions/setup-node from 4.0.3 to 4.0.4 (830cdd6)

2.0.9 (2024-09-09)

Bug Fixes

  • deps: bump actions/checkout from 4.1.5 to 4.1.6 (558d1ab)
  • deps: bump actions/checkout from 4.1.6 to 4.1.7 (51a44db)
  • deps: bump actions/setup-node from 4.0.2 to 4.0.3 (e7c25bc)

2.0.8 (2024-05-08)

Bug Fixes

  • deps: bump actions/checkout from 4.1.2 to 4.1.3 (43e0d22)
  • deps: bump actions/checkout from 4.1.3 to 4.1.4 (46a73c8)
  • deps: bump actions/checkout from 4.1.4 to 4.1.5 (5f1323e)

2.0.7 (2024-03-29)

Bug Fixes

  • deps: bump actions/checkout from 4.1.1 to 4.1.2 (bf2523d)
  • deps: bump actions/setup-node from 4.0.1 to 4.0.2 (534c4cb)

2.0.6 (2024-02-03)

Bug Fixes

  • deps: bump actions/setup-node from 4.0.0 to 4.0.1 (6111f45)
  • deps: bump actions/stale from 8.0.0 to 9.0.0 (e640bae)

2.0.5 (2023-12-02)

2.0.4 (2023-11-01)

Bug Fixes

  • deps: bump actions/checkout from 3.5.3 to 3.6.0 (1e93540)
  • deps: bump actions/checkout from 3.6.0 to 4.0.0 (b06d641)
  • deps: bump actions/checkout from 4.0.0 to 4.1.0 (b3d8e14)
  • deps: bump actions/checkout from 4.1.0 to 4.1.1 (bca09de)
  • deps: bump actions/setup-node from 3.7.0 to 3.8.0 (646e059)
  • deps: bump actions/setup-node from 3.8.0 to 3.8.1 (9147ecb)
  • deps: bump actions/setup-node from 3.8.1 to 4.0.0 (28f890a)

2.0.3 (2023-08-09)

Bug Fixes

  • :pencil2: remove global from vite (a50f000)
  • deps: bump actions/checkout from 3.5.2 to 3.5.3 (9040d96)
  • deps: bump actions/setup-node from 3.6.0 to 3.7.0 (d180516)

2.0.2 (2023-05-23)

Bug Fixes

  • deps: bump actions/checkout from 3.3.0 to 3.5.2 (4285689)
  • deps: bump actions/stale from 7.0.0 to 8.0.0 (5ea1bd6)

2.0.1 (2023-02-05)

Bug Fixes

  • deps: bump actions/checkout from 3.1.0 to 3.2.0 (09573c2)
  • deps: bump actions/checkout from 3.2.0 to 3.3.0 (5c008b6)
  • deps: bump actions/setup-node from 3.5.1 to 3.6.0 (c5aa6f1)
  • deps: bump actions/stale from 6.0.1 to 7.0.0 (c374f48)

2.0.0 (2022-10-16)

⚠ BREAKING CHANGES

  • replace the deprecated interface
  • remove tslint as it is deprecated
  • export the function
  • :beers: rename snake-naming to main

Features

  • :beers: rename snake-naming to main (b5fdb52)

Bug Fixes

  • deps: bump actions/checkout from 2.4.0 to 3.1.0 (4c38435)
  • deps: bump actions/setup-node from 2.5.0 to 3.4.1 (9f045ce)
  • deps: bump actions/setup-node from 3.4.1 to 3.5.1 (6e9baac)
  • deps: bump actions/stale from 4 to 5.1.0 (3248a10)
  • deps: bump actions/stale from 5.1.0 to 5.1.1 (48dd8f6)
  • deps: bump actions/stale from 5.1.1 to 6.0.0 (5d652a5)
  • deps: bump actions/stale from 6.0.0 to 6.0.1 (e6c581e)
  • replace the deprecated interface (a8be33c)
  • export the function (2308223)
  • remove tslint as it is deprecated (58700ee)

1.0.0 (2021-12-17)

Bug Fixes

  • :beer: fixed eslint run (14c919e)