Compare commits

...

6 Commits
dev ... legacy

Author SHA1 Message Date
francesco.spilla
249c68afa6 custom prettier config 2021-01-14 14:18:11 +01:00
francesco.spilla
e51a2e587f do not specify @index (primary keys only) 2021-01-14 14:17:53 +01:00
francesco.spilla
74be5631f6 specify @columns even if they are in a relation 2021-01-14 14:15:28 +01:00
francesco.spilla
61a39768fe custom comments in entity.mst 2021-01-14 14:14:54 +01:00
francesco.spilla
b1fdd92583 custom naming strategy 2021-01-14 14:14:36 +01:00
francesco.spilla
47663de08f fix import filename in index.mst 2021-01-14 14:12:05 +01:00
6 changed files with 18 additions and 5 deletions

View File

@ -89,7 +89,7 @@ export default function modelCustomizationPhase(
}
namingStrategy.enablePluralization(generationOptions.pluralizeNames);
let retVal = removeIndicesGeneratedByTypeorm(dbModel);
retVal = removeColumnsInRelation(dbModel);
//retVal = removeColumnsInRelation(dbModel);
retVal = applyNamingStrategy(namingStrategy, dbModel);
retVal = addImportsAndGenerationOptions(retVal, generationOptions);
retVal = removeColumnDefaultProperties(retVal, defaultValues);

View File

@ -12,6 +12,9 @@ import { Relation } from "./models/Relation";
const prettierOptions: Prettier.Options = {
parser: "typescript",
endOfLine: "auto",
singleQuote: true,
trailingComma: "all",
printWidth: 1000,
};
export default function modelGenerationPhase(

View File

@ -67,7 +67,7 @@ export function relationName(relation: Relation, owner?: Entity): string {
}
export function entityName(oldEntityName: string, entity?: Entity): string {
return oldEntityName;
return oldEntityName + "Entity";
}
export function columnName(oldColumnName: string, column?: Column): string {
@ -75,5 +75,5 @@ export function columnName(oldColumnName: string, column?: Column): string {
}
export function fileName(oldFileName: string): string {
return oldFileName;
return oldFileName.replace("Entity", ".entity");
}

View File

@ -340,7 +340,7 @@ export default class MssqlDriver extends AbstractDriver {
records.forEach((record) => {
indexInfo.columns.push(record.ColumnName);
});
ent.indices.push(indexInfo);
if (indexInfo.primary) ent.indices.push(indexInfo);
});
});

View File

@ -35,7 +35,17 @@ import {{localImport (toEntityName entityName)}} from './{{toFileName fileName}}
@Entity("{{sqlName}}"{{#schema}} ,{schema:"{{.}}"{{#if ../database}}, database:"{{../database}}"{{/if}} } {{/schema}})
export {{defaultExport}} class {{toEntityName tscName}}{{#activeRecord}} extends BaseEntity{{/activeRecord}} {
{{#if columns}}
// Columns
{{/if~}}
{{#columns}}{{> Column}}{{/columns~}}
{{#if relations}}
// Relations
{{/if~}}
{{#relations}}{{> Relation}}{{/relations~}}
{{#relationIds}}{{> RelationId entityName=../tscName}}{{/relationIds~}}
{{#if generateConstructor}}{{>Constructor entityName=tscName}}{{/if~}}

View File

@ -1,5 +1,5 @@
{{#entities~}}
import {{localImport (toEntityName tscName)}} from './{{toFileName tscName}}'
import {{localImport (toEntityName tscName)}} from './{{toFileName fileName}}'
{{/entities}}
export { {{#entities}}{{toEntityName tscName}},{{/entities~}} }