insertintosite_data(field,data)values('UNDER_CONSTRUCTION_TEXT','NGSplanner.com is currently under construction! Please check back after Sig yells at me enough to help finish it.');
insertintosite_data(name,data)values('UNDER_CONSTRUCTION_TEXT','NGSplanner.com is currently under construction! Please check back after Sig yells at me enough to help finish it.');
if(Number.isNaN(Number(req.body[field]))){returnfield+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"}else{returnfield+"=$"+(i+1)}
if(Number.isNaN(Number(req.body[field]))){returnfield+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"}else{returnfield+"=$"+(i+1)}
}}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]])
}}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeofreq.body[field]==='string'?req.body[field].trim():req.body[field]),req.body["name"]])
.then((data)=>{
.then((data)=>{
if(data.rows.length===0){
if(data.rows.length===0){
requiresInsert=true
requiresInsert=true
@ -447,7 +452,7 @@ function CreateDynamicEndpoints() {
db.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>{
db.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>{
if(!field.includes("_id")){return"$"+(i+1)}else{
if(!field.includes("_id")){return"$"+(i+1)}else{
if(Number.isNaN(Number(req.body[field]))){return"(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"}else{return"$"+(i+1)}
if(Number.isNaN(Number(req.body[field]))){return"(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"}else{return"$"+(i+1)}
if(Number.isNaN(Number(req.body[field]))){returnfield+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"}else{returnfield+"=$"+(i+1)}
if(Number.isNaN(Number(req.body[field]))){returnfield+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"}else{returnfield+"=$"+(i+1)}
}}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]])
}}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeofreq.body[field]==='string'?req.body[field].trim():req.body[field]),req.body["name"]])
.then((data)=>{
.then((data)=>{
if(data.rows.length===0){
if(data.rows.length===0){
requiresInsert=true
requiresInsert=true
@ -494,7 +499,7 @@ function CreateDynamicEndpoints() {
db.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>{
db.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>{
if(!field.includes("_id")){return"$"+(i+1)}else{
if(!field.includes("_id")){return"$"+(i+1)}else{
if(Number.isNaN(Number(req.body[field]))){return"(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"}else{return"$"+(i+1)}
if(Number.isNaN(Number(req.body[field]))){return"(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"}else{return"$"+(i+1)}
returndb.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])
returndb.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)=>typeofreq.body[field]==='string'?req.body[field].trim():req.body[field]),req.body.id])
}else{
}else{
varmsg="Could not authenticate!";res.status(500).send(msg);throwmsg
varmsg="Could not authenticate!";res.status(500).send(msg);throwmsg
}
}
@ -540,7 +545,7 @@ function CreateDynamicEndpoints() {
awaitdb2.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"]])
awaitdb2.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)=>typeofreq.body[field]==='string'?req.body[field].trim():req.body[field]),req.body["name"]])
.then((data)=>{
.then((data)=>{
if(data.rows.length===0){
if(data.rows.length===0){
requiresInsert=true
requiresInsert=true
@ -620,7 +625,7 @@ function CreateDynamicEndpoints() {
})
})
}
}
if(requiresInsert){
if(requiresInsert){
db2.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]))
db2.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)=>typeofreq.body[field]==='string'?req.body[field].trim():req.body[field]))
.then((data)=>{
.then((data)=>{
res.status(200).json(data.rows)
res.status(200).json(data.rows)
})
})
@ -636,14 +641,14 @@ function CreateDynamicEndpoints() {
returndb2.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])
returndb2.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)=>typeofreq.body[field]==='string'?req.body[field].trim():req.body[field]),req.body.id])
}else{
}else{
varmsg="Could not authenticate!";res.status(500).send(msg);throwmsg
varmsg="Could not authenticate!";res.status(500).send(msg);throwmsg
}
}
@ -661,7 +666,7 @@ function CreateDynamicEndpoints() {
returndb.query('update builds set creator=$1,build_name=$2,class1=(SELECT id from class WHERE name=$3 limit 1),class2=(SELECT id from class WHERE name=$4 limit 1),last_modified=$5,data=$6 where id=$7 returning id',[req.body.creator,req.body.build_name,req.body.class1,req.body.class2,newDate(),req.body.data,req.body.id])
.then((data)=>{
if(send){
res.status(200).send(data.rows[0])
}
})
.catch((err)=>{
console.log(err.message)
if(send){
res.status(500).send(err.message)
}
})
}else{
returndb.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,newDate(),newDate(),0,req.body.data,0])
.then((data)=>{
if(send){
res.status(200).send(data.rows[0])
}
})
.catch((err)=>{
console.log(err.message)
if(send){
res.status(500).send(err.message)
}
})
}
})
.catch((err)=>{
console.log(err.message)
if(send){
res.status(500).send(err.message)
}
})
}else{
db.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,newDate(),newDate(),0,req.body.data,0])