db4.query('select * from password where password=$1',[req.body.pass])
.then((data)=>{
if(data.rows.length>0){
db.end(()=>{})
db.end(()=>{})
db2.end(()=>{})
db2.end(()=>{})
db3.query('select pg_terminate_backend (pid) from pg_stat_activity where pg_stat_activity.datname=\'ngsplanner\' or pg_stat_activity.datname=\'ngsplanner2\'')
returndb3.query('select pg_terminate_backend (pid) from pg_stat_activity where pg_stat_activity.datname=\'ngsplanner\' or pg_stat_activity.datname=\'ngsplanner2\'')
}else{
varmsg="Could not authenticate!";res.status(500).send(msg);throwmsg
}
})
.then(()=>{
.then(()=>{
returndb3.query('drop database ngsplanner')
returndb3.query('drop database ngsplanner')
})
})
@ -292,9 +322,16 @@ for (var test of ["","/test"]) {
db4.query('select * from password where password=$1',[req.body.pass])
.then((data)=>{
if(data.rows.length>0){
db.end(()=>{})
db.end(()=>{})
db2.end(()=>{})
db2.end(()=>{})
db3.query('select pg_terminate_backend (pid) from pg_stat_activity where pg_stat_activity.datname=\'ngsplanner\' or pg_stat_activity.datname=\'ngsplanner2\'')
returndb3.query('select pg_terminate_backend (pid) from pg_stat_activity where pg_stat_activity.datname=\'ngsplanner\' or pg_stat_activity.datname=\'ngsplanner2\'')
}else{
varmsg="Could not authenticate!";res.status(500).send(msg);throwmsg
}
})
.then(()=>{
.then(()=>{
returndb3.query('drop database ngsplanner2')
returndb3.query('drop database ngsplanner2')
})
})
@ -324,9 +361,16 @@ for (var test of ["","/test"]) {
awaitdb.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]])
awaitmydb.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]])
.then((data)=>{
.then((data)=>{
if(data.rows.length===0){
if(data.rows.length===0){
requiresInsert=true
requiresInsert=true
@ -399,7 +454,7 @@ function CreateDynamicEndpoints() {
})
})
}
}
if(requiresInsert){
if(requiresInsert){
db.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>"$"+(i+1)).join(",")+") returning *",all_filled_fields.map((field)=>req.body[field]))
mydb.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>"$"+(i+1)).join(",")+") returning *",all_filled_fields.map((field)=>req.body[field]))
.then((data)=>{
.then((data)=>{
res.status(200).json(data.rows)
res.status(200).json(data.rows)
})
})
@ -407,29 +462,26 @@ function CreateDynamicEndpoints() {
db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+" where id=$"+(all_filled_fields.length+1)+" returning *",[...all_filled_fields.map((field)=>req.body[field]),req.body.id])
returnmydb.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+" where id=$"+(all_filled_fields.length+1)+" returning *",[...all_filled_fields.map((field)=>req.body[field]),req.body.id])
.then((data)=>{
res.status(200).json(data.rows)
})
.catch((err)=>{
res.status(500).send(err.message)
})
}else{
}else{
res.status(300).send("Invalid query!")
varmsg="Could not authenticate!";res.status(500).send(msg);throwmsg
db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+" where id=$"+(all_filled_fields.length+1)+" returning *",[...all_filled_fields.map((field)=>req.body[field]),req.body.id])
.then((data)=>{
.then((data)=>{
res.status(200).json(data.rows)
if(data.rows.length>0){
})
returnmydb.query('delete from '+endpoint.endpoint+' where id=$1 returning *',[req.body.id])
.catch((err)=>{
res.status(500).send(err.message)
})
}else{
}else{
res.status(300).send("Invalid query!")
varmsg="Could not authenticate!";res.status(500).send(msg);throwmsg