typeorm-naming-strategies

Custom naming strategies for typeorm

typeorm-naming-strategies downloads typeorm-naming-strategies version typeorm-naming-strategies license

typeorm-naming-strategiesSimilar Packages:

Npm Package Weekly Downloads Trend

3 Years
🌟 Show real-time usage chart on typeorm-naming-strategies's README.md, just copy the code below.
## Usage Trend
[![Usage Trend of typeorm-naming-strategies](https://npm-compare.com/img/npm-trend/THREE_YEARS/typeorm-naming-strategies.png)](https://npm-compare.com/typeorm-naming-strategies#timeRange=THREE_YEARS)

Cumulative GitHub Star Trend

🌟 Show GitHub stars trend chart on typeorm-naming-strategies's README.md, just copy the code below.
## GitHub Stars Trend
[![GitHub Stars Trend of typeorm-naming-strategies](https://npm-compare.com/img/github-trend/typeorm-naming-strategies.png)](https://npm-compare.com/typeorm-naming-strategies)

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
typeorm-naming-strategies333,3982185.08 kB28-MIT

README for typeorm-naming-strategies

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(),
}