Apply "iterative" database approach to new backend.

pull/10/head
sigonasr2, Sig, Sigo 3 years ago
parent ab93edc998
commit 7f5f409897
  1. 10
      server/app.js

@ -180,6 +180,15 @@ const ENDPOINTDATA=[
function CreateDynamicEndpoints() {
ENDPOINTDATA.map((endpoint)=>{
app.get("/ngsplanner/"+endpoint.endpoint,(req,res)=>{
if (endpoint.requiredfields.includes("name")) {
db2.query('select distinct on (name) name,* from '+endpoint.endpoint+' order by name,id desc')
.then((data)=>{
res.status(200).json({fields:data.fields,rows:data.rows})
})
.catch((err)=>{
res.status(500).send(err.message)
})
} else {
db2.query('select * from '+endpoint.endpoint+" order by id desc")
.then((data)=>{
res.status(200).json({fields:data.fields,rows:data.rows})
@ -187,6 +196,7 @@ function CreateDynamicEndpoints() {
.catch((err)=>{
res.status(500).send(err.message)
})
}
})

Loading…
Cancel
Save