Skip to content

moomdate/typeorm-naming-strategies

 
 

Repository files navigation

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 { PascalNamingStrategy } from 'typeorm-naming-strategies';

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

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

// Use require instead of import
const PascalNamingStrategy = require("typeorm-naming-strategies").PascalNamingStrategy

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

About

Custom naming strategies for typeorm, Pascal Case

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.6%
  • JavaScript 1.4%