-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAgenda.ts
More file actions
49 lines (42 loc) · 1.3 KB
/
Agenda.ts
File metadata and controls
49 lines (42 loc) · 1.3 KB
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
import { Transform, Type } from 'class-transformer';
import { IsBoolean, IsInt, IsOptional, Min, ValidateNested } from 'class-validator';
import { Column, Entity, JoinTable, ManyToMany, ManyToOne } from 'typeorm';
import { InputData, ListChunk } from '../Base';
import { User } from '../User';
import { ActivityBaseFilter } from './Activity';
import { ForumBase } from './Forum';
@Entity()
export class Agenda extends ForumBase {
@Type(() => User)
@Transform(({ value }) => (Array.isArray(value) ? value.map(user => User.from(user)) : value))
@ValidateNested()
@IsOptional()
@ManyToMany(() => User, { nullable: true })
@JoinTable()
mentors?: User[];
@IsBoolean()
@Column({ default: false })
adopted?: boolean;
}
export abstract class AgendaBase extends ForumBase {
@Type(() => Agenda)
@Transform(({ value }) => Agenda.from(value))
@ValidateNested()
@IsOptional()
@ManyToOne(() => Agenda)
agenda: Agenda;
}
export class AgendaBaseFilter extends ActivityBaseFilter implements Partial<InputData<AgendaBase>> {
@IsInt()
@Min(1)
@IsOptional()
agenda?: number;
}
export class AgendaListChunk implements ListChunk<Agenda> {
@IsInt()
@Min(0)
count: number;
@Type(() => Agenda)
@ValidateNested({ each: true })
list: Agenda[];
}