const router = require("express").Router();
const Employee = require("../models/Employee");

// CREATE
router.post("/", async (req, res) => {
  res.json(await Employee.create(req.body));
});

// READ
router.get("/", async (req, res) => {
  res.json(await Employee.find());
});

// UPDATE
router.put("/:id", async (req, res) => {
  res.json(await Employee.findByIdAndUpdate(req.params.id, req.body));
});

// DELETE
router.delete("/:id", async (req, res) => {
  res.json(await Employee.findByIdAndDelete(req.params.id));
});

module.exports = router;