aboutsummaryrefslogtreecommitdiff
path: root/src/db/model/User.ts
blob: f3ec9627803ff4a1c23d0e71d8c784b807997781 (plain) (blame)
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
import * from 'sequelize-typescript';
import { default as UserGroup } from './UserGroup';
import { default as Project } from './Project';
import { default as UserJoinsProject } './UserJoinsProject';
import { default as File } './File';

@Table
export default class User extends Model<User> {
  @Column
  @PrimaryKey
  username: string;

  @Column
  @NotNull
  password: string;

  @Column
  @ForeignKey(() => UserGroup)
  userGroupId: number;

  @BelongsTo(() => UserGroup)
  userGroup: UserGroup;

  @BelongsToMany(() => Project, () => UserJoinsProject)
  projects: Project[];

  @HasMany(() => File)
  createdFiles: File[];

  @CreatedAt
  creationDate: Date;
}