import { plural } from 'pluralize' ; import { DefaultNamingStrategy } from 'typeorm' ; import { snakeCase } from 'typeorm/util/StringUtils' ; export class NamingStrategy extends DefaultNamingStrategy { tableName ( targetName , userSpecifiedName ) { return plural ( snakeCase ( userSpecifiedName || targetName ) ) ; } relationName ( propertyName ) { return snakeCase ( propertyName ) ; } columnName ( propertyName , customName ) { return snakeCase ( customName || propertyName ) ; } joinColumnName ( relationName , referencedColumnName ) { return snakeCase ( `${ relationName }_${ referencedColumnName }` ) ; } joinTableColumnName ( tableName , propertyName , columnName ) { return snakeCase ( `${ tableName }_${ columnName || propertyName }` ) ; } }