@graf-research/adf-codegen-model-typeorm 0.0.10 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/exec.js +0 -0
- package/dist/index.js +16 -2
- package/package.json +1 -1
package/dist/exec.js
CHANGED
File without changes
|
package/dist/index.js
CHANGED
@@ -112,9 +112,12 @@ var TypeORMModel;
|
|
112
112
|
}
|
113
113
|
}
|
114
114
|
function buildColumnCommon(type, column, list_model) {
|
115
|
-
var _a, _b;
|
115
|
+
var _a, _b, _c, _d, _e;
|
116
116
|
const null_attr = ((_a = column.attributes) !== null && _a !== void 0 ? _a : []).find((attr) => attr.type === 'null');
|
117
117
|
const default_value_attr = ((_b = column.attributes) !== null && _b !== void 0 ? _b : []).find((attr) => attr.type === 'default');
|
118
|
+
const primary_key_attr = ((_c = column.attributes) !== null && _c !== void 0 ? _c : []).find((attr) => attr.type === 'primary-key');
|
119
|
+
const unique_attr = ((_d = column.attributes) !== null && _d !== void 0 ? _d : []).find((attr) => attr.type === 'unique');
|
120
|
+
const autoinc_attr = ((_e = column.attributes) !== null && _e !== void 0 ? _e : []).find((attr) => attr.type === 'autoincrement');
|
118
121
|
const is_required = null_attr ? !null_attr.value : false;
|
119
122
|
const has_default_value = Boolean(default_value_attr);
|
120
123
|
const typeorm_decorator = [
|
@@ -126,6 +129,17 @@ var TypeORMModel;
|
|
126
129
|
].filter(Boolean).map(line => ' ' + line),
|
127
130
|
`})`,
|
128
131
|
];
|
132
|
+
if (primary_key_attr === null || primary_key_attr === void 0 ? void 0 : primary_key_attr.value) {
|
133
|
+
if (autoinc_attr === null || autoinc_attr === void 0 ? void 0 : autoinc_attr.value) {
|
134
|
+
typeorm_decorator.push(`@PrimaryGeneratedColumn('increment')`);
|
135
|
+
}
|
136
|
+
else {
|
137
|
+
typeorm_decorator.push(`@PrimaryColumn()`);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
if (unique_attr === null || unique_attr === void 0 ? void 0 : unique_attr.value) {
|
141
|
+
// something to do with unique
|
142
|
+
}
|
129
143
|
return [
|
130
144
|
...typeorm_decorator,
|
131
145
|
`${column.name}${is_required ? '!' : '?'}: ${sqlTypeToJSType(type)};`
|
@@ -239,7 +253,7 @@ var TypeORMModel;
|
|
239
253
|
files: [{
|
240
254
|
filename: getModelFileName(table, '.ts'),
|
241
255
|
content: [
|
242
|
-
'import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn, BaseEntity } from "typeorm";',
|
256
|
+
'import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryColumn, PrimaryGeneratedColumn, UpdateDateColumn, BaseEntity } from "typeorm";',
|
243
257
|
...lodash_1.default.uniq(buildTableDependency(table, list_model)),
|
244
258
|
'',
|
245
259
|
`@Entity('${table.name}')`,
|