Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
828 B
2
Indexable
Never
export class CustomNamingStrategy extends DefaultNamingStrategy {
  tableName(className: string, customName: string): string {
    const tableName = super.tableName(className, customName);
    return this.conventioningName(tableName, customName);
  }

  columnName(propertyName: string, customName: string, embeddedPrefixes: string[]): string {
    const propName = super.columnName(propertyName, customName, embeddedPrefixes);
    return this.conventioningName(propName, customName);
  }

  relationName(propertyName: string): string {
    const relName = super.relationName(propertyName);
    return this.conventioningName(relName);
  }

  private conventioningName(objName: string, customName?: string) {
    const name = (customName && objName) || snakeCase(objName).toUpperCase();
    return name;
  }
}