From 540a8f23dfda0789afcdafce0ee32855b2ed51fb Mon Sep 17 00:00:00 2001 From: onsaliyo Date: Thu, 29 Apr 2021 17:03:12 +0200 Subject: [PATCH] add Evento para insert y update --- src/database/consultas.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/database/consultas.js b/src/database/consultas.js index bd63cb2..fab65fe 100644 --- a/src/database/consultas.js +++ b/src/database/consultas.js @@ -56,16 +56,16 @@ module.exports.getDiscoteca = getDiscoteca; async function addEvento(evento){ try{ let conn = await mariadb.getConn(); - const lookup = await conn.query ("SELECT * FROM evento WHERE id = ?", [evento.id]); + var rows = await conn.query ("SELECT * FROM evento WHERE id = ?", [evento.id]); conn.release(); - if (!lookup){ - const rows = await conn.query + if (!rows){ + rows = await conn.query ("INSERT INTO evento (discotecaID, nombre, localizacion, fecha, hora, descripcion, precio1, precio2) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", [evento.discotecaID, evento.nombre, evento.localizacion, evento.fecha, evento.hora, evento.descripcion, evento.precio1, evento.precio2]); conn.release();} else{ - const rows = await conn.query + rows = await conn.query ("UPDATE evento SET discotecaID = ?, nombre = ?, localizacion = ?, fecha = ?, hora = ?, descripcion = ?, precio1 = ?, precio2 = ? WHERE id = ?", [evento.discotecaID, evento.nombre, evento.localizacion, evento.fecha, evento.hora, evento.descripcion, evento.precio1, evento.precio2, evento.id]); }