Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tonivj5/typeorm-naming-strategies
Custom naming strategies for typeorm
https://github.com/tonivj5/typeorm-naming-strategies
naming-strategies snake strategy typeorm typeorm-naming typeorm-plugin
Last synced: about 1 month ago
JSON representation
Custom naming strategies for typeorm
- Host: GitHub
- URL: https://github.com/tonivj5/typeorm-naming-strategies
- Owner: tonivj5
- License: mit
- Created: 2018-09-11T15:23:46.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-11-28T17:22:34.000Z (10 months ago)
- Last Synced: 2024-05-17T19:43:53.080Z (4 months ago)
- Topics: naming-strategies, snake, strategy, typeorm, typeorm-naming, typeorm-plugin
- Language: TypeScript
- Size: 988 KB
- Stars: 200
- Watchers: 5
- Forks: 26
- Open Issues: 26
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```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(), // Here you'r using the strategy!
});
```Alternatively you can use it in combination with a `ormconfig.js`
```js
// Use require instead of import
const SnakeNamingStrategy = require("typeorm-naming-strategies").SnakeNamingStrategymodule.exports = {
...
namingStrategy: new SnakeNamingStrategy(),
}
```