cuestionario, seccion, pregunta y opcion listos
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
const Opcion = require(`../../db/tablas/Opcion`);
|
||||
const validar = require(`../../helper/validar`);
|
||||
|
||||
const editar = async (body) => {
|
||||
const idOpcion = validar.validarNumeroEntero(body.idOpcion, 'idOpcion');
|
||||
const opcion = validar.validacionBasicaStr(body.opcion, 'opcion', false, 256);
|
||||
|
||||
return Opcion.findOne({ where: { idOpcion } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe esta opción.');
|
||||
return Opcion.update(
|
||||
{
|
||||
opcion,
|
||||
},
|
||||
{ where: { idOpcion } }
|
||||
);
|
||||
})
|
||||
.then((res) => ({
|
||||
message: 'Se actualizó correctamente la opción.',
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = editar;
|
||||
Reference in New Issue
Block a user