DBLabs/abitur_list_client/mongo/controllers/specialization.controller.js

37 lines
1.6 KiB
JavaScript
Raw Normal View History

const mymongodb = require('../../mongoIndex')
const SpecializationControllerInterface = require('../../controllers/interfaces/specialization.controller.interface');
const { ObjectId } = require('mongodb');
class SpecializationController extends SpecializationControllerInterface {
async createSpecialization(req, res) {
// const {title} = req.body
// const newSpecialization = await db.query('INSERT INTO specialization (title) VALUES ($1) RETURNING *', [title])
// res.json(newSpecialization.rows[0])
}
async getSpecializations(req, res) {
// const specializations = await db.query('SELECT * FROM specialization')
// res.json(specializations.rows)
const specializations = await mymongodb.collection('specializations').find().toArray()
res.json(specializations)
}
async getOneSpecialization(req, res) {
// const id = req.params.id
// const specializations = await db.query('SELECT * FROM specialization WHERE id=$1', [id])
// res.json(specializations.rows[0])
}
async updateSpecialization(req, res) {
// const {id, title} = req.body
// const newSpecialization = await db.query('UPDATE specialization SET title=$1 WHERE id=$2 RETURNING *', [title, id])
// res.json(newSpecialization.rows[0])
}
async deleteSpecialization(req, res) {
// const id = req.params.id
// const specializations = await db.query('DELETE FROM specialization WHERE id=$1', [id])
// res.json(specializations.rows[0])
}
}
module.exports = new SpecializationController()