| 87 | } |
| 88 | |
| 89 | @Entity() |
| 90 | @Index({ properties: ['name', 'age'] }) |
| 91 | @Index({ name: 'custom_idx_name_123', properties: ['name'] }) |
| 92 | @Unique({ properties: ['name', 'email'] }) |
| 93 | class Author { |
| 94 | static beforeDestroyCalled = 0; |
| 95 | static afterDestroyCalled = 0; |
| 96 | |
| 97 | @PrimaryKey({ type: 'integer' }) |
| 98 | id!: number; |
| 99 | |
| 100 | @Property({ default: sql.now() }) |
| 101 | createdAt: Opt<Date> = new Date(); |
| 102 | |
| 103 | @Property({ onUpdate: () => new Date(), default: sql.now() }) |
| 104 | updatedAt: Opt<Date> = new Date(); |
| 105 | |
| 106 | @Property({ type: 'string' }) |
| 107 | name: string; |
| 108 | |
| 109 | @Property({ type: 'string', unique: 'custom_email_unique_name', groups: ['personal', 'admin'] }) |
| 110 | @Index({ name: 'custom_email_index_name' }) |
| 111 | email: string; |
| 112 | |
| 113 | @Property({ type: 'integer', nullable: true, default: null, groups: ['personal', 'admin'] }) |
| 114 | age?: number; |
| 115 | |
| 116 | @Index() |
| 117 | @Property({ type: 'boolean', groups: ['admin'] }) |
| 118 | termsAccepted: Opt<boolean> = false; |
| 119 | |
| 120 | @Property({ type: 'boolean', nullable: true, groups: ['personal'] }) |
| 121 | optional?: boolean; |
| 122 | |
| 123 | @Property({ type: 'string[]', nullable: true, groups: ['admin'] }) |
| 124 | identities?: string[]; |
| 125 | |
| 126 | @Property({ type: 'date', index: true, nullable: true, groups: ['personal', 'admin'] }) |
| 127 | born?: string; |
| 128 | |
| 129 | @ManyToMany({ entity: () => Author, pivotTable: 'author_to_friend', groups: ['personal'] }) |
| 130 | friends = new Collection<Author>(this); |
| 131 | |
| 132 | @ManyToMany(() => Author, undefined, { groups: ['personal'] }) |
| 133 | following = new Collection<Author>(this); |
| 134 | |
| 135 | @ManyToMany(() => Author, a => a.following, { groups: ['personal'] }) |
| 136 | followers = new Collection<Author>(this); |
| 137 | |
| 138 | @ManyToOne(() => Author, { nullable: true, groups: ['personal'] }) |
| 139 | favouriteAuthor?: Author | null; |
| 140 | |
| 141 | @Embedded(() => Identity, { nullable: true, object: true, groups: ['personal', 'admin'] }) |
| 142 | identity?: Identity; |
| 143 | |
| 144 | @Property({ type: 'integer', persist: false }) |
| 145 | version!: number & Opt; |
| 146 |
nothing calls this directly
no test coverage detected