Untitled

 avatar
unknown
plain_text
2 years ago
828 B
4
Indexable
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;
  }
}
Editor is loading...