new model files

This commit is contained in:
Kononnable 2019-09-26 20:35:10 +02:00
parent 7a2395ab2a
commit a13da7848e
4 changed files with 72 additions and 0 deletions

33
src/models/Column.ts Normal file
View File

@ -0,0 +1,33 @@
import { ColumnType } from "typeorm";
export type Column = {
primary?: boolean;
sqlType: ColumnType;
typescriptType: any;
name?: string;
length?: number;
width?: number;
nullable?: boolean;
generated?: true | "increment" | "uuid";
unique?: boolean;
default?: boolean;
precision?: number;
scale?: number;
unsigned?: boolean;
enum?: string[];
array?: boolean;
};

15
src/models/Entity.ts Normal file
View File

@ -0,0 +1,15 @@
import { Column } from "./Column";
import { Relation } from "./Relation";
import { Index } from "./Index";
export type Entity = {
sqlName: string;
typescriptName?: string;
database?: string;
schema?: string;
columns: Column[];
relations?: Relation[];
indices?: Index[];
};

5
src/models/Index.ts Normal file
View File

@ -0,0 +1,5 @@
export type Index = {
name?: string;
columns?: ((object?: any) => any[] | { [key: string]: number }) | string[];
unique?: boolean;
};

19
src/models/Relation.ts Normal file
View File

@ -0,0 +1,19 @@
import { OnUpdateType } from "typeorm/metadata/types/OnUpdateType";
import { OnDeleteType } from "typeorm/metadata/types/OnDeleteType";
import { RelationType } from "typeorm/metadata/types/RelationTypes";
import { JoinTableOptions, JoinColumnOptions } from "typeorm";
import { JoinTableMultipleColumnsOptions } from "typeorm/decorator/options/JoinTableMultipleColumnsOptions";
export type Relation = {
target: Function | string;
type: RelationType;
inverseSide?: string;
// lazy?: boolean;
// eager?: boolean;
// primary?: boolean;
joinTable?: boolean | JoinTableOptions | JoinTableMultipleColumnsOptions;
joinColumn?: boolean | JoinColumnOptions;
nullable?: boolean;
onDelete?: OnDeleteType;
onUpdate?: OnUpdateType;
};