SIU_Dran_net/Server/Controller/DAORegistro.js

22 lines
731 B
JavaScript
Raw Normal View History

2024-06-03 14:13:02 +00:00
import Conexion from './Conexion.js';
import logger from '../utils/logger.js';
2024-05-25 05:38:51 +00:00
class DAORegistro {
static async registrar(usuario, descripcion, day) {
const conexion = new Conexion();
const conexionEstablecida = await conexion.conectar();
try {
const sql = "INSERT INTO registro (matricula, descripcion) VALUES (?, ?)";
2024-06-03 04:59:59 +00:00
const stm = await conexionEstablecida.query(sql, [usuario, descripcion + day]);
2024-05-25 05:38:51 +00:00
return stm.affectedRows > 0;
} catch (error) {
2024-06-03 04:59:59 +00:00
logger.error(`Error en DAORegistro.registrar: ${error.message}`);
2024-05-25 05:38:51 +00:00
return false;
} finally {
conexion.cerrarConexion();
}
}
}
export default DAORegistro;