22 lines
598 B
JavaScript
22 lines
598 B
JavaScript
const Premiacion = require('../../db/tablas/Premiacion');
|
|
const { validarNumeroEntero, validarFecha } = require('../../helper/validar');
|
|
|
|
const editar = async (body) => {
|
|
let fecha;
|
|
let hora;
|
|
if (body.fecha) fecha = validarFecha(body.fecha);
|
|
if (body.hora) hora = body.hora;
|
|
|
|
const idPremiacion = validarNumeroEntero(
|
|
body.idPremiacion,
|
|
'idPremiacion',
|
|
true
|
|
);
|
|
|
|
const premiacion = await Premiacion.findOne({ where: idPremiacion });
|
|
if (!premiacion) throw new Error('No existe esta premiación.');
|
|
return premiacion.update({ fecha, hora});
|
|
};
|
|
|
|
module.exports = editar;
|