diff --git a/README.md b/README.md index 593121a..11a7aac 100644 --- a/README.md +++ b/README.md @@ -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! }); ``` diff --git a/package-lock.json b/package-lock.json index 5055287..44c11ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { - "name": "express-typescript-starter", - "version": "0.1.0", + "name": "typeorm-naming-strategies", + "version": "1.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -837,9 +837,9 @@ } }, "typescript": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", - "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.3.tgz", + "integrity": "sha512-kk80vLW9iGtjMnIv11qyxLqZm20UklzuR2tL0QAnDIygIUIemcZMxlMWudl9OOt76H3ntVzcTiddQ1/pAAJMYg==", "dev": true }, "which": { diff --git a/package.json b/package.json index d2b95b1..3ceab36 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,19 @@ { "name": "typeorm-naming-strategies", - "version": "1.0.1", + "version": "1.0.2", "description": "Custom naming strategies for typeorm", "main": "index.js", "types": "index.d.ts", "keywords": [ "typeorm", + "naming", + "strategy", + "node", + "orm", "naming strategy", "snake strategy", - "typeorm snake" + "typeorm snake", + "naming strategies" ], "repository": { "type": "git", @@ -17,17 +22,17 @@ "author": "Toni Villena", "license": "MIT", "scripts": { - "build": "rm -rf dist && tsc && cp README.md package.json dist/", - "build:watch": "tsc -w" + "build": "rm -rf dist && npm run tsc && cp README.md package.json dist/", + "tsc": "tsc" }, "dependencies": {}, - "peerDependencies": { - "typeorm": "^0.2" - }, "devDependencies": { "@types/node": "^9.4.6", + "tslint": "^5.11.0", "typeorm": "^0.2", - "tslint": "^5.9.1", - "typescript": "^2.7.2" + "typescript": "^3.0.3" + }, + "peerDependencies": { + "typeorm": "^0.2.7" } } diff --git a/src/index.ts b/src/index.ts index cff982f..45f3b11 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1 @@ -export { SnakeNamingStrategy } from 'snake-naming.strategy'; +export { SnakeNamingStrategy } from './snake-naming.strategy'; diff --git a/tsconfig.json b/tsconfig.json index bdd2349..7c0101f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,14 +2,15 @@ "compilerOptions": { "module": "commonjs", "esModuleInterop": true, + "allowSyntheticDefaultImports": true, "target": "es6", "noImplicitAny": true, "declaration": true, + "removeComments": true, "moduleResolution": "node", "sourceMap": false, "strict": true, - "outDir": "dist", - "baseUrl": "src" + "outDir": "dist" }, "include": ["src/**/*"] }