-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
57 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,44 @@ | ||
# typeorm-naming-strategies | ||
# Typeorm naming strategies | ||
|
||
Custom naming strategies for typeorm | ||
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. | ||
|
||
# How to use | ||
For example, using the snake strategy, if you have a model like this: | ||
|
||
```typescript | ||
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](https://www.npmjs.com/package/typeorm-naming-strategies) | ||
|
||
```sh | ||
npm install typeorm-naming-strategies --save | ||
``` | ||
|
||
Or using yarn | ||
|
||
```sh | ||
yarn add typeorm-naming-strategies | ||
``` | ||
|
||
## Usage | ||
|
||
```typescript | ||
import { createConnection } from 'typeorm'; | ||
import { SnakeNamingStrategy } from 'typeorm-naming-strategies'; | ||
|
||
await createConnection({ | ||
... | ||
namingStrategy: new SnakeNamingStrategy(), | ||
namingStrategy: new SnakeNamingStrategy(), // Here you'r using the strategy! | ||
}); | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { SnakeNamingStrategy } from 'snake-naming.strategy'; | ||
export { SnakeNamingStrategy } from './snake-naming.strategy'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters