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

router.post("/", async (req, res) => res.json(await Department.create(req.body)));
router.get("/", async (req, res) => res.json(await Department.find()));
router.put("/:id", async (req, res) => res.json(await Department.findByIdAndUpdate(req.params.id, req.body)));
router.delete("/:id", async (req, res) => res.json(await Department.findByIdAndDelete(req.params.id)));

module.exports = router;