var express = require("express");
const router = express.Router();
const db = require("../../utils/database");

router.get("/getPriority", (req, res) => {
  db.getConnection((err, connection) => {
    if (err) {
      console.log("database not connected error: >>>", err);
      throw err;
    }
    console.log("get Connection");
    var getQuery = `select * from finehhdi_eDefect.UsersPriority order by id desc`;
    connection.query(getQuery, (err, result) => {
        connection.release()
      if (err) {
        res.status(500).send({
          message: "error from server",
          result: "Faild",
        });
      } else {
        res.status(201).send({
          message: "getPriority successfully",
          result: "Success",
          data: result,
        });
      }
    });
    console.log("release Connection");
  });
});

module.exports = router;
