UNPKG

5.03 kBTypeScriptView Raw
1import { ColumnType } from "../driver/types/ColumnTypes";
2import { ValueTransformer } from "../decorator/options/ValueTransformer";
3import { SpatialColumnOptions } from "../decorator/options/SpatialColumnOptions";
4export interface EntitySchemaColumnOptions extends SpatialColumnOptions {
5 /**
6 * Indicates if this column is a primary column.
7 */
8 primary?: boolean;
9 /**
10 * Indicates if this column is of type ObjectID
11 */
12 objectId?: boolean;
13 /**
14 * Indicates if this column is a created date column.
15 */
16 createDate?: boolean;
17 /**
18 * Indicates if this column is an update date column.
19 */
20 updateDate?: boolean;
21 /**
22 * Indicates if this column is a version column.
23 */
24 version?: boolean;
25 /**
26 * Indicates if this column is a treeChildrenCount column.
27 */
28 treeChildrenCount?: boolean;
29 /**
30 * Indicates if this column is a treeLevel column.
31 */
32 treeLevel?: boolean;
33 /**
34 * Column type. Must be one of the value from the ColumnTypes class.
35 */
36 type: ColumnType;
37 /**
38 * Column name in the database.
39 */
40 name?: string;
41 /**
42 * Column type's length. For example type = "string" and length = 100 means that ORM will create a column with
43 * type varchar(100).
44 */
45 length?: string | number;
46 /**
47 * Column type's display width. Used only on some column types in MySQL.
48 * For example, INT(4) specifies an INT with a display width of four digits.
49 */
50 width?: number;
51 /**
52 * Indicates if column's value can be set to NULL.
53 */
54 nullable?: boolean;
55 /**
56 * Indicates if column value is not updated by "save" operation.
57 * It means you'll be able to write this value only when you first time insert the object.
58 * Default value is "false".
59 *
60 * @deprecated Please use the `update` option instead. Careful, it takes
61 * the opposite value to readonly.
62 *
63 */
64 readonly?: boolean;
65 /**
66 * Indicates if column value is updated by "save" operation.
67 * If false you'll be able to write this value only when you first time insert the object.
68 * Default value is "true".
69 */
70 update?: boolean;
71 /**
72 * Indicates if column is always selected by QueryBuilder and find operations.
73 * Default value is "true".
74 */
75 select?: boolean;
76 /**
77 * Indicates if column is inserted by default.
78 * Default value is "true".
79 */
80 insert?: boolean;
81 /**
82 * Specifies if this column will use AUTO_INCREMENT or not (e.g. generated number).
83 */
84 generated?: true | "increment" | "uuid" | "rowid";
85 /**
86 * Specifies if column's value must be unique or not.
87 */
88 unique?: boolean;
89 /**
90 * Extra column definition. Should be used only in emergency situations. Note that if you'll use this property
91 * auto schema generation will not work properly anymore. Avoid using it.
92 */
93 columnDefinition?: string;
94 /**
95 * Column comment.
96 */
97 comment?: string;
98 /**
99 * Default database value.
100 */
101 default?: any;
102 /**
103 * ON UPDATE trigger. Works only for MySQL.
104 */
105 onUpdate?: string;
106 /**
107 * The precision for a decimal (exact numeric) column (applies only for decimal column), which is the maximum
108 * number of digits that are stored for the values.
109 */
110 precision?: number;
111 /**
112 * The scale for a decimal (exact numeric) column (applies only for decimal column), which represents the number
113 * of digits to the right of the decimal point and must not be greater than precision.
114 */
115 scale?: number;
116 /**
117 * Puts ZEROFILL attribute on to numeric column. Works only for MySQL.
118 * If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column
119 */
120 zerofill?: boolean;
121 /**
122 * Puts UNSIGNED attribute on to numeric column. Works only for MySQL.
123 */
124 unsigned?: boolean;
125 /**
126 * Defines a column character set.
127 * Not supported by all database types.
128 */
129 charset?: string;
130 /**
131 * Defines a column collation.
132 */
133 collation?: string;
134 /**
135 * Array of possible enumerated values.
136 */
137 enum?: any[] | Object;
138 /**
139 * Generated column expression. Supports only in MySQL.
140 */
141 asExpression?: string;
142 /**
143 * Generated column type. Supports only in MySQL.
144 */
145 generatedType?: "VIRTUAL" | "STORED";
146 /**
147 * Return type of HSTORE column.
148 * Returns value as string or as object.
149 */
150 hstoreType?: "object" | "string";
151 /**
152 * Indicates if this column is an array.
153 * Can be simply set to true or array length can be specified.
154 * Supported only by postgres.
155 */
156 array?: boolean;
157 /**
158 * Specifies a value transformer that is to be used to (un)marshal
159 * this column when reading or writing to the database.
160 */
161 transformer?: ValueTransformer | ValueTransformer[];
162}