/
Publisher2.ts
67 lines (49 loc) · 1.43 KB
/
Publisher2.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { Collection, Entity, Enum, EnumType, ManyToMany, OneToMany, OptionalProps, Property } from '@mikro-orm/core';
import { Book2 } from './Book2';
import { Test2 } from './Test2';
import { BaseEntity2 } from './BaseEntity2';
export enum PublisherType {
LOCAL = 'local',
GLOBAL = 'global',
}
export enum PublisherType2 {
LOCAL = 'LOCAL',
GLOBAL = 'GLOBAL',
}
export const enum Enum1 {
Value1,
Value2,
}
export enum Enum2 {
PROP1 = 1,
PROP2 = 2,
}
@Entity()
export class Publisher2 extends BaseEntity2 {
[OptionalProps]?: 'type' | 'type2' | 'hookTest';
@Property({ fieldName: 'name' })
name: string;
@OneToMany(() => Book2, 'publisher', { joinColumn: 'book_uuid', inverseJoinColumn: 'publisher_id' })
books = new Collection<Book2>(this);
@ManyToMany({ entity: () => Test2, pivotTable: 'publisher2_tests', fixedOrder: true })
tests = new Collection<Test2>(this);
@Enum(() => PublisherType)
type = PublisherType.LOCAL;
@Enum(() => PublisherType2)
type2 = PublisherType2.LOCAL;
@Enum({ nullable: true, type: EnumType })
enum1?: Enum1;
@Enum({ type: 'Enum2', nullable: true })
enum2?: Enum2;
@Enum({ items: [1, 2, 3], nullable: true })
enum3?: any;
@Enum({ items: ['a', 'b', 'c'], nullable: true })
enum4?: any;
@Enum({ items: ['a'], nullable: true })
enum5?: any;
constructor(name = 'asd', type = PublisherType.LOCAL) {
super();
this.name = name;
this.type = type;
}
}