const db = require("../db/db");

const getVideo = () => {
  const sql = `SELECT * FROM video`;
  return new Promise((resolve, reject) => {
    db.query(sql, (err, results) => {
      if (err) {
        reject(err);
      } else {
        resolve(results);
      }
    });
  });
};

const updateVideo = (id, Link) => {
  const sql = `UPDATE video SET Link = ? WHERE idVideo = ?`;
  return new Promise((resolve, reject) => {
    db.query(sql, [Link, id], (err, results) => {
      if (err) {
        reject(err);
      } else {
        resolve(results);
      }
    });
  });
};
module.exports = {
  getVideo,
  updateVideo,
};
