DBLabs/abitur_list_client/controllers/request_examresult.controller.js

23 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

const db = require('../db')
const Request_ExamResultControllerInterface = require('./interfaces/request_examresult.controller.interface')
class Request_ExamResultController extends Request_ExamResultControllerInterface {
async createRecord(req, res) {
const {request_id, exam_result_id} = req.body
const newRecord = await db.query('INSERT INTO request_exam_result (request_id, exam_result_id) VALUES ($1, $2) RETURNING *', [request_id, exam_result_id])
res.json(newRecord.rows[0])
}
async getRecords(req, res) {
const id = req.params.id
const records = await db.query('SELECT * FROM request_exam_result WHERE request_id=$1', [id])
res.json(records.rows)
}
async deleteRecord(req, res) {
const {request_id, exam_result_id} = req.body
const records = await db.query('DELETE FROM request_exam_result WHERE request_id=$1 AND exam_result_id=$2', [request_id, exam_result_id])
res.json(records.rows[0])
}
}
module.exports = new Request_ExamResultController()