db4.query('select * from password where password=$1',[req.body.pass])
.then((data)=>{
if(data.rows.length>0){
db.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(()=>{
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(()=>{})
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(()=>{
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)=>{
if(data.rows.length===0){
requiresInsert=true
@ -399,7 +454,7 @@ function CreateDynamicEndpoints() {
})
}
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)=>{
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])
.then((data)=>{
res.status(200).json(data.rows)
})
.catch((err)=>{
res.status(500).send(err.message)
})
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])
}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])
db4.query('select * from password where password=$1',[req.body.pass])
.then((data)=>{
res.status(200).json(data.rows)
})
.catch((err)=>{
res.status(500).send(err.message)
})
if(data.rows.length>0){
returnmydb.query('delete from '+endpoint.endpoint+' where id=$1 returning *',[req.body.id])
}else{
res.status(300).send("Invalid query!")
varmsg="Could not authenticate!";res.status(500).send(msg);throwmsg