Skip to content

Commit 9555636

Browse files
Create/update schemas for admin, position, user
1 parent 595e0a2 commit 9555636

File tree

4 files changed

+54
-1
lines changed

4 files changed

+54
-1
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {
2+
Column,
3+
DataType,
4+
ForeignKey,
5+
Model,
6+
Table,
7+
} from "sequelize-typescript";
8+
import User from "./user.model";
9+
10+
@Table({ tableName: "admins" })
11+
export default class Admin extends Model {
12+
@ForeignKey(() => User)
13+
@Column({ type: DataType.STRING, primaryKey: true })
14+
userId!: string;
15+
16+
@Column({ type: DataType.ARRAY(DataType.STRING) })
17+
authorizedDepartments!: string[];
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Column, DataType, Model, Table } from "sequelize-typescript";
2+
import { Department } from "../types";
3+
4+
@Table({ tableName: "positions" })
5+
export default class Position extends Model {
6+
@Column({ type: DataType.STRING, primaryKey: true })
7+
title!: string;
8+
9+
@Column({ type: DataType.ENUM(...Object.values(Department)) })
10+
department!: string;
11+
}

backend/typescript/models/user.model.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
/* eslint import/no-cycle: 0 */
22

3-
import { Column, DataType, HasMany, Model, Table } from "sequelize-typescript";
3+
import {
4+
Column,
5+
DataType,
6+
ForeignKey,
7+
HasMany,
8+
Model,
9+
Table,
10+
} from "sequelize-typescript";
411
import { Role } from "../types";
512
import ApplicationDashboardTable from "./applicationDashboard.model";
13+
import Position from "./position.model";
614

715
@Table({ tableName: "users" })
816
export default class User extends Model {
@@ -24,6 +32,10 @@ export default class User extends Model {
2432
@Column({ type: DataType.ENUM("User", "Admin") })
2533
role!: Role;
2634

35+
@ForeignKey(() => Position)
36+
@Column({ type: DataType.STRING })
37+
position!: string;
38+
2739
@HasMany(() => ApplicationDashboardTable)
2840
applicationDashboards?: ApplicationDashboardTable[];
2941
}

backend/typescript/types.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,15 @@ export enum ApplicantRole {
125125
uxr = "user researcher", // design tab
126126
dev = "project developer", // eng tab
127127
}
128+
129+
export enum Department {
130+
ENGINEERING = "Engineering",
131+
DESIGN = "Design",
132+
PRODUCT = "Product",
133+
COMMUNITY = "Community",
134+
}
135+
136+
export type Position = {
137+
title: string;
138+
department: Department;
139+
};

0 commit comments

Comments
 (0)