4.1.0 • Published 2 years ago

typeorm-naming-strategies v4.1.0

Weekly downloads
33,064
License
MIT
Repository
github
Last release
2 years ago

Typeorm naming strategies

This package provides a few (one, at the moment) useful custom naming strategies. It alterates the name of columns, relations and other fields in 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-strategies --save

Or using yarn

yarn add typeorm-naming-strategies

Usage

import { createConnection } from 'typeorm';
import { SnakeNamingStrategy } from 'typeorm-naming-strategies';

await 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-strategies").SnakeNamingStrategy

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

2 years ago

4.0.0

2 years ago

3.0.0

2 years ago

1.2.0

4 years ago

2.0.0

4 years ago

1.3.0

4 years ago

1.1.0

5 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago