-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtables.js
111 lines (106 loc) · 1.81 KB
/
tables.js
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import { DataTypes } from "sequelize";
export const PERSON = [
"PERSON",
{
uuid: {
type: DataTypes.UUID,
primaryKey: true,
},
firstName: {
type: DataTypes.TEXT,
allowNull: false,
},
lastName: {
type: DataTypes.TEXT,
allowNull: false,
},
phoneNumber: {
type: DataTypes.TEXT,
allowNull: false,
},
birthDate: {
type: DataTypes.TEXT,
allowNull: false,
},
},
];
export const STUDENT = (model) => [
"STUDENT",
{
personId: {
type: DataTypes.UUID,
unique: true,
references: {
model,
key: "uuid",
},
},
stipend: {
type: DataTypes.REAL,
},
},
];
export const TEACHER = (model) => [
"TEACHER",
{
personId: {
type: DataTypes.UUID,
unique: true,
references: {
model,
key: "uuid",
},
},
salary: {
type: DataTypes.REAL,
allowNull: false,
},
},
];
export const COURSE = (model) => [
"COURSE",
{
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true,
},
name: {
type: DataTypes.TEXT,
allowNull: false,
},
credits: {
type: DataTypes.INTEGER,
allowNull: false,
},
teacherId: {
type: DataTypes.UUID,
allowNull: false,
references: {
model,
key: "personId",
},
},
},
];
export const STUDENT_TO_COURSE = (studentModel, courseModel) => [
"STUDENT_TO_COURSE",
{
studentId: {
type: DataTypes.UUID,
allowNull: false,
references: {
model: studentModel,
key: "personId",
},
},
courseId: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: courseModel,
key: "id",
},
},
},
];