const { sequelize, Sequelize } = require('../models') const db = require('../models') db.employees = require('../models/employee')(sequelize, Sequelize) const Employee = db.employees exports.getEmployees = (req, res) => { Employee.findAll() .then(data => { res.send(data); }) .catch(err => { res.status(500).send({ message: err.message || "Hiba! Az adatbázis lekérése sikertelen" }) }) } exports.create = (req, res) => { if(!req.body.name) { res.status(400).send({ message: "A név megadása kötelező" }) return } const employee = { name: req.body.name, city: req.body.city, salary: req.body.salary } Employee.create(employee) .then( result => { res.send(result) }) }