|
294 | 294 | `bit`, `int`, `integer`, `tinyint`, `smallint`, `mediumint`, `bigint`, `float`, `double`,
|
295 | 295 | `double precision`, `dec`, `decimal`, `numeric`, `fixed`, `bool`, `boolean`, `date`, `datetime`,
|
296 | 296 | `timestamp`, `time`, `year`, `char`, `nchar`, `national char`, `varchar`, `nvarchar`, `national varchar`,
|
297 |
| -`text`, `tinytext`, `mediumtext`, `blob`, `longtext`, `tinyblob`, `mediumblob`, `longblob`, `enum`, |
| 297 | +`text`, `tinytext`, `mediumtext`, `blob`, `longtext`, `tinyblob`, `mediumblob`, `longblob`, `enum`, `set`, |
298 | 298 | `json`, `binary`, `varbinary`, `geometry`, `point`, `linestring`, `polygon`, `multipoint`, `multilinestring`,
|
299 | 299 | `multipolygon`, `geometrycollection`
|
300 | 300 |
|
|
307 | 307 | `date`, `time`, `time without time zone`, `time with time zone`, `interval`, `bool`, `boolean`,
|
308 | 308 | `enum`, `point`, `line`, `lseg`, `box`, `path`, `polygon`, `circle`, `cidr`, `inet`, `macaddr`,
|
309 | 309 | `tsvector`, `tsquery`, `uuid`, `xml`, `json`, `jsonb`, `int4range`, `int8range`, `numrange`,
|
310 |
| -`tsrange`, `tstzrange`, `daterange`, `geometry`, `geography` |
| 310 | +`tsrange`, `tstzrange`, `daterange`, `geometry`, `geography`, `cube` |
311 | 311 |
|
312 | 312 | ### Column types for `cockroachdb`
|
313 | 313 |
|
@@ -390,6 +390,52 @@ export class User {
|
390 | 390 | }
|
391 | 391 | ```
|
392 | 392 |
|
| 393 | +### `set` column type |
| 394 | + |
| 395 | +`set` column type is supported by `mariadb` and `mysql`. There are various possible column definitions: |
| 396 | + |
| 397 | +Using typescript enums: |
| 398 | +```typescript |
| 399 | +export enum UserRole { |
| 400 | + ADMIN = "admin", |
| 401 | + EDITOR = "editor", |
| 402 | + GHOST = "ghost" |
| 403 | +} |
| 404 | + |
| 405 | +@Entity() |
| 406 | +export class User { |
| 407 | + |
| 408 | + @PrimaryGeneratedColumn() |
| 409 | + id: number; |
| 410 | + |
| 411 | + @Column({ |
| 412 | + type: "set", |
| 413 | + enum: UserRole, |
| 414 | + default: [UserRole.GHOST, UserRole.EDITOR] |
| 415 | + }) |
| 416 | + roles: UserRole[] |
| 417 | + |
| 418 | +} |
| 419 | +``` |
| 420 | + |
| 421 | +Using array with `set` values: |
| 422 | +```typescript |
| 423 | +export type UserRoleType = "admin" | "editor" | "ghost", |
| 424 | + |
| 425 | +@Entity() |
| 426 | +export class User { |
| 427 | + |
| 428 | + @PrimaryGeneratedColumn() |
| 429 | + id: number; |
| 430 | + |
| 431 | + @Column({ |
| 432 | + type: "set", |
| 433 | + enum: ["admin", "editor", "ghost"], |
| 434 | + default: ["ghost", "editor"] |
| 435 | + }) |
| 436 | + roles: UserRoleType[] |
| 437 | +} |
| 438 | +``` |
393 | 439 |
|
394 | 440 | ### `simple-array` column type
|
395 | 441 |
|
|
0 commit comments