Database changes and trims
This commit is contained in:
parent
03e7144eae
commit
5e06a7f812
@ -13,3 +13,17 @@ CREATE TABLE "skill_tree_data"("id" SERIAL UNIQUE PRIMARY KEY,"class_id" int,"da
|
|||||||
ALTER TABLE "skill_tree_data" ADD FOREIGN KEY ("class_id") REFERENCES "class" ("id");
|
ALTER TABLE "skill_tree_data" ADD FOREIGN KEY ("class_id") REFERENCES "class" ("id");
|
||||||
alter table skill_tree_data add column halflineheight int;
|
alter table skill_tree_data add column halflineheight int;
|
||||||
CREATE TABLE "site_data" ("id" SERIAL UNIQUE PRIMARY KEY,"field" text,"data" text);
|
CREATE TABLE "site_data" ("id" SERIAL UNIQUE PRIMARY KEY,"field" text,"data" text);
|
||||||
|
alter table class_skill_data alter column damage_taken set data type text;
|
||||||
|
alter table class_skill_data alter column pa_potency set data type text;
|
||||||
|
alter table class_skill_data alter column conditional_buff set data type text;
|
||||||
|
alter table class_skill_data alter column pp_recovery set data type text;
|
||||||
|
alter table class_skill_data alter column property set data type text;
|
||||||
|
alter table class_skill_data alter column all_damage_buff set data type text;
|
||||||
|
alter table class_skill_data alter column active_pp_recovery set data type text;
|
||||||
|
alter table class_skill_data alter column status_ailment_accum set data type text;
|
||||||
|
alter table class_skill_data alter column status_ailment_duration set data type text;
|
||||||
|
alter table class_skill_data alter column pp_consumption set data type text;
|
||||||
|
alter table class_skill_data alter column max_hp_decrease set data type text;
|
||||||
|
alter table class_skill_data alter column natural_pp_recovery set data type text;
|
||||||
|
alter table class_skill_data alter column pb_gauge_fortification set data type text;
|
||||||
|
alter table site_data rename column field to name;
|
@ -117,7 +117,7 @@ CREATE TABLE "armor" (
|
|||||||
"crit_dmg" float,
|
"crit_dmg" float,
|
||||||
"pp_cost_reduction" float,
|
"pp_cost_reduction" float,
|
||||||
"active_pp_recovery" float,
|
"active_pp_recovery" float,
|
||||||
"natural_pp_recovery" float,
|
"natural_pp_recovery" text,
|
||||||
"dmg_res" float,
|
"dmg_res" float,
|
||||||
"all_down_res" float,
|
"all_down_res" float,
|
||||||
"burn_res" float,
|
"burn_res" float,
|
||||||
@ -247,20 +247,20 @@ CREATE TABLE "class_skill_data" (
|
|||||||
"effect" text,
|
"effect" text,
|
||||||
"duration" int,
|
"duration" int,
|
||||||
"cooldown" int,
|
"cooldown" int,
|
||||||
"damage_taken" float,
|
"damage_taken" text,
|
||||||
"pa_potency" float,
|
"pa_potency" text,
|
||||||
"conditional_buff" boolean,
|
"conditional_buff" boolean,
|
||||||
"pp_recovery" float,
|
"pp_recovery" text,
|
||||||
"property" text,
|
"property" text,
|
||||||
"all_damage_buff" float,
|
"all_damage_buff" text,
|
||||||
"active_pp_recovery" float,
|
"active_pp_recovery" text,
|
||||||
"status_ailment_accum" float,
|
"status_ailment_accum" text,
|
||||||
"status_ailment_duration" float,
|
"status_ailment_duration" text,
|
||||||
"pp_consumption" float,
|
"pp_consumption" text,
|
||||||
"max_hp_decrease" float,
|
"max_hp_decrease" text,
|
||||||
"natural_pp_recovery" float,
|
"natural_pp_recovery" text,
|
||||||
"added_pp" int,
|
"added_pp" int,
|
||||||
"pb_gauge_fortification" float
|
"pb_gauge_fortification" text
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE "database_audit" (
|
CREATE TABLE "database_audit" (
|
||||||
@ -322,7 +322,7 @@ CREATE TABLE "skill_tree_data" (
|
|||||||
|
|
||||||
CREATE TABLE "site_data" (
|
CREATE TABLE "site_data" (
|
||||||
"id" SERIAL UNIQUE PRIMARY KEY,
|
"id" SERIAL UNIQUE PRIMARY KEY,
|
||||||
"field" text,
|
"name" text,
|
||||||
"data" text
|
"data" text
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -268,15 +268,15 @@ insert into class_skill(name,class_id,icon,description)
|
|||||||
values('Assault Charge Advent',(SELECT id from class WHERE name='Gunner' limit 1),'','This is ');
|
values('Assault Charge Advent',(SELECT id from class WHERE name='Gunner' limit 1),'','This is ');
|
||||||
|
|
||||||
insert into class_skill_data(name,class_skill_id,dependency,level,effect,duration,cooldown,damage_taken,pa_potency,conditional_buff,pp_recovery,property,all_damage_buff,active_pp_recovery,status_ailment_accum,status_ailment_duration,pp_consumption,max_hp_decrease,natural_pp_recovery,added_pp,pb_gauge_fortification)
|
insert into class_skill_data(name,class_skill_id,dependency,level,effect,duration,cooldown,damage_taken,pa_potency,conditional_buff,pp_recovery,property,all_damage_buff,active_pp_recovery,status_ailment_accum,status_ailment_duration,pp_consumption,max_hp_decrease,natural_pp_recovery,added_pp,pb_gauge_fortification)
|
||||||
values('Hunter Physique Lv.1',(SELECT id from class_skill WHERE name='Hunter Physique' limit 1),'',1,'Effect Name',20,15,0.7,1,false,0.5,'',0,0,0,0,0,0,0,0,0);
|
values('Hunter Physique Lv.1',(SELECT id from class_skill WHERE name='Hunter Physique' limit 1),'',1,'Effect Name',20,15,'0.7','1',false,'0.5','','0','0','0','0','0','0','0',0,'0');
|
||||||
insert into class_skill_data(name,class_skill_id,dependency,level,effect,duration,cooldown,damage_taken,pa_potency,conditional_buff,pp_recovery,property,all_damage_buff,active_pp_recovery,status_ailment_accum,status_ailment_duration,pp_consumption,max_hp_decrease,natural_pp_recovery,added_pp,pb_gauge_fortification)
|
insert into class_skill_data(name,class_skill_id,dependency,level,effect,duration,cooldown,damage_taken,pa_potency,conditional_buff,pp_recovery,property,all_damage_buff,active_pp_recovery,status_ailment_accum,status_ailment_duration,pp_consumption,max_hp_decrease,natural_pp_recovery,added_pp,pb_gauge_fortification)
|
||||||
values('War Cry Lv.1',(SELECT id from class_skill WHERE name='War Cry' limit 1),'',1,'Effect Name',14,10,0.5,1.1,false,0.8,'',0,0,0,0.6,0,0,0,0,0);
|
values('War Cry Lv.1',(SELECT id from class_skill WHERE name='War Cry' limit 1),'',1,'Effect Name',14,10,0.5,'1.1','0.8',false,'0.6','','0','0','0','0','0','0','0',0,'0');
|
||||||
insert into class_skill_data(name,class_skill_id,dependency,level,effect,duration,cooldown,damage_taken,pa_potency,conditional_buff,pp_recovery,property,all_damage_buff,active_pp_recovery,status_ailment_accum,status_ailment_duration,pp_consumption,max_hp_decrease,natural_pp_recovery,added_pp,pb_gauge_fortification)
|
insert into class_skill_data(name,class_skill_id,dependency,level,effect,duration,cooldown,damage_taken,pa_potency,conditional_buff,pp_recovery,property,all_damage_buff,active_pp_recovery,status_ailment_accum,status_ailment_duration,pp_consumption,max_hp_decrease,natural_pp_recovery,added_pp,pb_gauge_fortification)
|
||||||
values('War Cry Lv.2',(SELECT id from class_skill WHERE name='War Cry' limit 1),'',2,'Effect Name',11,11,0.8,1.0,false,0.7,'',0,0,0,0.9,0,0,0,0,0);
|
values('War Cry Lv.2',(SELECT id from class_skill WHERE name='War Cry' limit 1),'',2,'Effect Name',11,11,'0.8','1',false,'0.5','','0','0','0','0','0','0','0',0,'0');
|
||||||
insert into class_skill_data(name,class_skill_id,dependency,level,effect,duration,cooldown,damage_taken,pa_potency,conditional_buff,pp_recovery,property,all_damage_buff,active_pp_recovery,status_ailment_accum,status_ailment_duration,pp_consumption,max_hp_decrease,natural_pp_recovery,added_pp,pb_gauge_fortification)
|
insert into class_skill_data(name,class_skill_id,dependency,level,effect,duration,cooldown,damage_taken,pa_potency,conditional_buff,pp_recovery,property,all_damage_buff,active_pp_recovery,status_ailment_accum,status_ailment_duration,pp_consumption,max_hp_decrease,natural_pp_recovery,added_pp,pb_gauge_fortification)
|
||||||
values('Assault Charge Advent',(SELECT id from class_skill WHERE name='Assault Charge Advent' limit 1),'',1,'Effect Name',30,24,1.0,1.1,false,0.8,'',0,0,0,0,0,0,0.6,0,0);
|
values('Assault Charge Advent',(SELECT id from class_skill WHERE name='Assault Charge Advent' limit 1),'',1,'Effect Name',30,24,'1.8','1',false,'0.5','','0','0','0','0','0','0','0',0,'1.6');
|
||||||
|
|
||||||
insert into skill_tree_data(class_id,data,skill_data,line_color,line_width,gridsizex,gridsizey,gridpaddingx,gridpaddingy,halflineheight)
|
insert into skill_tree_data(class_id,data,skill_data,line_color,line_width,gridsizex,gridsizey,gridpaddingx,gridpaddingy,halflineheight)
|
||||||
values((select id from class where name='Hunter'),'□ □ ,└□─┘□□, │ ││, │ □│, □─□┼□, □ ','','#000000',3,80,60,10,10,60);
|
values((select id from class where name='Hunter'),'□ □ ,└□─┘□□, │ ││, │ □│, □─□┼□, □ ','','#000000',3,80,60,10,10,60);
|
||||||
|
|
||||||
insert into site_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.');
|
insert into site_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.');
|
102
server.js
102
server.js
@ -229,7 +229,7 @@ const ENDPOINTDATA=[
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
endpoint:"site_data",
|
endpoint:"site_data",
|
||||||
requiredfields:["field","data"],
|
requiredfields:["name","data"],
|
||||||
optionalfields:[],
|
optionalfields:[],
|
||||||
excludedfields:[] //Fields to not output in GET.
|
excludedfields:[] //Fields to not output in GET.
|
||||||
}
|
}
|
||||||
@ -472,10 +472,14 @@ function CreateDynamicEndpoints() {
|
|||||||
var all_filled_fields=combinedfields.filter((field)=>(field in req.body))
|
var all_filled_fields=combinedfields.filter((field)=>(field in req.body))
|
||||||
var requiresInsert=true
|
var requiresInsert=true
|
||||||
if (endpoint.requiredfields.includes("name")) {
|
if (endpoint.requiredfields.includes("name")) {
|
||||||
|
/*console.log(['update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{
|
||||||
|
if (!field.includes("_id")) {return field+"=$"+(i+1)}else{
|
||||||
|
if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)}
|
||||||
|
}}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]]])*/
|
||||||
await db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{
|
await db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{
|
||||||
if (!field.includes("_id")) {return field+"=$"+(i+1)}else{
|
if (!field.includes("_id")) {return field+"=$"+(i+1)}else{
|
||||||
if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)}
|
if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(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)=>typeof req.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
|
||||||
@ -492,7 +496,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)}
|
||||||
}}).join(",")+") returning *",all_filled_fields.map((field)=>req.body[field]))
|
}}).join(",")+") returning *",all_filled_fields.map((field)=>typeof req.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)
|
||||||
})
|
})
|
||||||
@ -521,8 +525,10 @@ function CreateDynamicEndpoints() {
|
|||||||
if (endpoint.requiredfields.includes("name")) {
|
if (endpoint.requiredfields.includes("name")) {
|
||||||
await db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{
|
await db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{
|
||||||
if (!field.includes("_id")) {return field+"=$"+(i+1)}else{
|
if (!field.includes("_id")) {return field+"=$"+(i+1)}else{
|
||||||
if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)}
|
if (Number.isNaN(Number(req.body[field]))) {
|
||||||
}}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]])
|
console.log(field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")");
|
||||||
|
return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)}
|
||||||
|
}}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.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
|
||||||
@ -539,7 +545,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)}
|
||||||
}}).join(",")+") returning *",all_filled_fields.map((field)=>req.body[field]))
|
}}).join(",")+") returning *",all_filled_fields.map((field)=>typeof req.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)
|
||||||
})
|
})
|
||||||
@ -551,11 +557,19 @@ function CreateDynamicEndpoints() {
|
|||||||
res.status(500).send("Could not authenticate!")
|
res.status(500).send("Could not authenticate!")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.catch((err)=>{
|
||||||
|
console.log(err.message)
|
||||||
|
res.status(500).send(err.message)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
res.status(500).send("Could not authenticate!")
|
res.status(500).send("Could not authenticate!")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.catch((err)=>{
|
||||||
|
console.log(err.message)
|
||||||
|
res.status(500).send(err.message)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
app.patch(PREFIX+"/"+endpoint.endpoint,(req,res)=>{
|
app.patch(PREFIX+"/"+endpoint.endpoint,(req,res)=>{
|
||||||
@ -651,7 +665,14 @@ function CreateDynamicEndpoints() {
|
|||||||
var all_filled_fields=combinedfields.filter((field)=>(field in req.body))
|
var all_filled_fields=combinedfields.filter((field)=>(field in req.body))
|
||||||
var requiresInsert=true
|
var requiresInsert=true
|
||||||
if (endpoint.requiredfields.includes("name")) {
|
if (endpoint.requiredfields.includes("name")) {
|
||||||
await db2.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"]])
|
/*console.log(['update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{
|
||||||
|
if (!field.includes("_id")) {return field+"=$"+(i+1)}else{
|
||||||
|
if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)}
|
||||||
|
}}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]]])*/
|
||||||
|
await db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{
|
||||||
|
if (!field.includes("_id")) {return field+"=$"+(i+1)}else{
|
||||||
|
if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)}
|
||||||
|
}}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.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
|
||||||
@ -665,7 +686,59 @@ 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)=>{
|
||||||
|
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)}
|
||||||
|
}}).join(",")+") returning *",all_filled_fields.map((field)=typeof req.body[field] === 'string'?req.body[field].trim():req.body[field]))
|
||||||
|
.then((data)=>{
|
||||||
|
res.status(200).json(data.rows)
|
||||||
|
})
|
||||||
|
.catch((err)=>{
|
||||||
|
res.status(500).send(err.message)
|
||||||
|
})
|
||||||
|
}app.post(PREFIX+"/"+endpoint.endpoint,async(req,res)=>{
|
||||||
|
db4.query('select * from password where password=$1',[req.body.pass])
|
||||||
|
.then(async(data)=>{
|
||||||
|
if (data.rows.length>0) {
|
||||||
|
var allExist=true
|
||||||
|
endpoint.requiredfields.forEach((field)=>{
|
||||||
|
if (!(field in req.body)) {
|
||||||
|
allExist=false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (!allExist) {
|
||||||
|
res.status(300).send("Required fields are: "+endpoint.requiredfields.filter((field)=>!(field in req.body)).join(','))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var combinedfields = [...endpoint.requiredfields,...endpoint.optionalfields,...endpoint.excludedfields]
|
||||||
|
//console.log(combinedfields)
|
||||||
|
var all_filled_fields=combinedfields.filter((field)=>(field in req.body))
|
||||||
|
var requiresInsert=true
|
||||||
|
if (endpoint.requiredfields.includes("name")) {
|
||||||
|
await db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{
|
||||||
|
if (!field.includes("_id")) {return field+"=$"+(i+1)}else{
|
||||||
|
if (Number.isNaN(Number(req.body[field]))) {
|
||||||
|
console.log(field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")");
|
||||||
|
return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)}
|
||||||
|
}}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.body[field] === 'string'?req.body[field].trim():req.body[field]),req.body["name"]])
|
||||||
|
.then((data)=>{
|
||||||
|
if (data.rows.length===0) {
|
||||||
|
requiresInsert=true
|
||||||
|
} else {
|
||||||
|
requiresInsert=false
|
||||||
|
res.status(200).json(data.rows)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err)=>{
|
||||||
|
res.status(500).send(err.message)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (requiresInsert) {
|
||||||
|
db2.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 (Number.isNaN(Number(req.body[field]))) {return "(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return "$"+(i+1)}
|
||||||
|
}}).join(",")+") returning *",all_filled_fields.map((field)=>typeof req.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)
|
||||||
})
|
})
|
||||||
@ -677,6 +750,19 @@ function CreateDynamicEndpoints() {
|
|||||||
res.status(500).send("Could not authenticate!")
|
res.status(500).send("Could not authenticate!")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.catch((err)=>{
|
||||||
|
console.log(err.message)
|
||||||
|
res.status(500).send(err.message)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
res.status(500).send("Could not authenticate!")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err)=>{
|
||||||
|
console.log(err.message)
|
||||||
|
res.status(500).send(err.message)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
app.patch(PREFIX+"/test/"+endpoint.endpoint,(req,res)=>{
|
app.patch(PREFIX+"/test/"+endpoint.endpoint,(req,res)=>{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user