Skip to content

Commit c247a70

Browse files
committed
refactor(tatakforms): database table names
1 parent f458114 commit c247a70

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

src/db/models/tatakform/admin.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ class TatakFormAdmin {
3030
`SELECT
3131
s.id, s.student_id, s.last_name, s.first_name, s.year_level, s.email_address, s.password, s.date_stamp, s.course_id, c.college_id, co.acronym, co.name
3232
FROM
33-
univ_admin a
33+
tatakforms_admin a
3434
INNER JOIN
35-
univ_students s ON s.id = a.univstudents_id
35+
tatakforms_students s ON s.id = a.tatakforms_students_id
3636
INNER JOIN
37-
colleges_courses c ON c.id = s.
37+
colleges_courses c ON c.id = s.course_id
3838
INNER JOIN
3939
colleges co on co.id = c.college_id
4040
WHERE
@@ -72,9 +72,9 @@ class TatakFormAdmin {
7272
`SELECT
7373
s.id, s.student_id, s.last_name, s.first_name, s.year_level, s.email_address, s.password, s.date_stamp, s.course_id, co.acronym, co.name
7474
FROM
75-
univ_admin a
75+
tatakforms_admin a
7676
INNER JOIN
77-
univ_students s ON s.id = a.univstudents_id
77+
tatakforms_students s ON s.id = a.tatakforms_students_id
7878
INNER JOIN
7979
colleges_courses c ON c.id = s.course_id
8080
INNER JOIN

src/db/models/tatakform/attendance.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class TatakFormAttendance {
8787
try {
8888
// Get admin by username
8989
const result = await db.query<[{ count: bigint }]>(
90-
"SELECT COUNT(*) as count FROM attendance WHERE student_id = ? and event_id = ?", [studentId, eventId]
90+
"SELECT COUNT(*) as count FROM tatakforms_attendance WHERE student_id = ? and event_id = ?", [studentId, eventId]
9191
);
9292

9393
// Resolve promise
@@ -113,7 +113,7 @@ class TatakFormAttendance {
113113
try {
114114
// Get attendance by event
115115
const result = await db.query<AttendanceModel[]>(
116-
"SELECT * FROM attendance WHERE student_id = ? and event_id = ?", [studentId, eventId]
116+
"SELECT * FROM tatakforms_attendance WHERE student_id = ? and event_id = ?", [studentId, eventId]
117117
);
118118

119119
resolve(result.length > 0 ? result[0] : null);
@@ -138,7 +138,7 @@ class TatakFormAttendance {
138138
try {
139139
// Get admin by username
140140
const result = await db.query<AttendanceModel[]>(
141-
"SELECT * FROM attendance WHERE student_id = ?", [studentId]
141+
"SELECT * FROM tatakforms_attendance WHERE student_id = ?", [studentId]
142142
);
143143
resolve([result, result.length]);
144144
}
@@ -166,7 +166,7 @@ class TatakFormAttendance {
166166
FROM
167167
attendance
168168
INNER JOIN
169-
univ_students s
169+
tatakforms_students s
170170
INNER JOIN
171171
colleges_courses c ON c.id = s.course_id
172172
WHERE
@@ -200,7 +200,7 @@ class TatakFormAttendance {
200200
try {
201201
// Get admin by username
202202
const result = await db.query<any>(
203-
`SELECT ${columnName} FROM attendance WHERE student_id = ? AND event_id = ?`, [studentId, eventId]
203+
`SELECT ${columnName} FROM tatakforms_attendance WHERE student_id = ? AND event_id = ?`, [studentId, eventId]
204204
);
205205

206206
// Resolve promise

src/db/models/tatakform/student.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TatakFormStudent {
3232
// Get pagination
3333
if (pagination && !isObjectEmpty(pagination)) {
3434
const { query, countQuery, values, countValues } = paginationWrapper(db, {
35-
query: "SELECT * FROM univ_students ORDER BY id DESC",
35+
query: "SELECT * FROM tatakforms_students ORDER BY id DESC",
3636
request: pagination
3737
});
3838

@@ -49,7 +49,7 @@ class TatakFormStudent {
4949
}
5050

5151
// Get all students
52-
const result = await db.query<UnivStudentModel[]>(`SELECT * FROM univ_students ORDER BY id DESC`);
52+
const result = await db.query<UnivStudentModel[]>(`SELECT * FROM tatakforms_students ORDER BY id DESC`);
5353

5454
// If no results
5555
if (result.length === 0) {
@@ -81,7 +81,7 @@ class TatakFormStudent {
8181

8282
try {
8383
// Query string
84-
let query = 'SELECT * FROM univ_students WHERE student_id = ?';
84+
let query = 'SELECT * FROM tatakforms_students WHERE student_id = ?';
8585

8686
// If getting data from admin
8787
if (fromAdmin) {
@@ -90,8 +90,9 @@ class TatakFormStudent {
9090
s.id, s.student_id, s.last_name, s.first_name,
9191
s.year_level, s.email_address, s.password, s.date_stamp, s.course_id
9292
FROM
93-
univ_admin a
94-
INNER JOIN univ_students s ON s.id = a.students_id WHERE s.student_id = ?
93+
tatakforms_admin a
94+
INNER JOIN
95+
tatakforms_students s ON s.id = a.students_id WHERE s.student_id = ?
9596
`;
9697
}
9798

@@ -151,7 +152,7 @@ class TatakFormStudent {
151152

152153
// Insert student
153154
const result = await db.query<MariaUpdateResult>(
154-
`INSERT INTO univ_students (student_id, year_level, first_name, last_name, course_id, email_address, password, date_stamp) VALUES (?, ?, ?,?, ?, ?, ?, NOW())`, [
155+
`INSERT INTO tatakforms_students (student_id, year_level, first_name, last_name, course_id, email_address, password, date_stamp) VALUES (?, ?, ?,?, ?, ?, ?, NOW())`, [
155156
student.student_id,
156157
student.year_level,
157158
student.first_name,
@@ -194,7 +195,7 @@ class TatakFormStudent {
194195
Log.i(`Checking if student exists (${key} = ${value})`);
195196
// Get result
196197
const result = await db.query<[{ count: bigint }]>(
197-
`SELECT COUNT(*) AS count FROM univ_students WHERE ${key} = ?`, [value]
198+
`SELECT COUNT(*) AS count FROM tatakforms_students WHERE ${key} = ?`, [value]
198199
);
199200

200201
// If no results

0 commit comments

Comments
 (0)