const { Sequelize } = require('sequelize') const Employee = require('../models/employee') const EmployeeController = { async index(req, res) { await Employee.findAll() .then( result => { res.status(200) res.json({ success: true, data: result }) }) .catch(error => { res.status(500) res.json({ success: false, message: 'Error! The query is failed!' }) }) }, async store(req, res) { const employee = { name: req.body.name, city: req.body.email, salary: req.body.password } await Employee.create(employee) .then( result => { res.status(201) res.json({ succes: true, data: result }) }) .catch(error => { const errorMessage = error.errors[0].message res.json({ access: false, error: errorMessage }) }) } } module.exports = EmployeeController