Agregar Id equipo

This commit is contained in:
2020-08-15 23:59:23 -05:00
parent e1ae80ae99
commit 7fcee0e220
2 changed files with 30 additions and 5 deletions
+9 -5
View File
@@ -100,7 +100,7 @@ function depurado(cadena) {
// );
app.post('/registro', async(req, res) => {
console.log(` Entor a registrarce `);
let body = req.body;
let idEquipo;
try{
@@ -159,10 +159,14 @@ app.post('/registro', async(req, res) => {
try{
let fecha = new Date();
let cad = `INSERT INTO Equipo VALUES (null, '${body.nombreEqui}', '${body.desafio}', '${body.campus}', ${body.numeroIntegrantes}, false, NOW());`;
await query(cad);
cad = `SELECT COUNT(*) as num FROM Equipo;`;
let ans = await query(cad);
idEquipo = ans[0].num;
let sqlAnswer = await query(cad);
cad = `SELECT LAST_INSERT_ID() as idEquipo;`;
sqlAnswer = await query(cad);
sqlAnswer = sqlAnswer[0];
idEquipo = sqlAnswer.idEquipo;
console.log(` ****************IDEUQIPO ${idEquipo}`);
}
catch(error){
+21
View File
@@ -43,3 +43,24 @@ ALTER TABLE `Persona` ADD FOREIGN KEY (`idEquipo`) REFERENCES `Equipo` (`idEquip
ALTER TABLE Equipo
ADD fechaRegistro Date;
alter table Equipo
drop fechaRegistro;
CREATE TABLE `Admin` (
`idUsuario` integer PRIMARY KEY NOT NULL AUTO_INCREMENT,
`usuario` varchar(100),
`password` varchar(100)
);
-- h4ch4#2020
INSERT INTO Admin VALUES (null, 'Administrador', '$2b$10$qM.oRmpQ3FjmPkq4m.l2JOx20X3grzTH71hP8emEQzUtApNqkie.G');
ALTER TABLE Equipo
ADD notificaInscripcion boolean;
ALTER TABLE Equipo
ADD fechaRegistro Date;