I have a postgres database where I am inserting data in three database tables. As I want to insert this data into all three tables on just one button click I dont want three different API endpoints. As I am new to node js and postgres I am unable to put all three queries in one api endpoint. Till now I am stuck at this-
app.post("/input",async(req,res)=>{
try{
const {a,b,c,d,e,f,g,h,i}= req.body;
const newentry=await pool.query(
"INSERT INTO num(a,b,c) VALUES($1,$2,$3) RETURNING *",
[a,b,c],
'INSERT INTO order(d,e,f) VALUES ($1,$2,$3) RETURNING *' ,
[d,e,f],
'INSERT INTO quantity(g,h,i) VALUES ($1,$2,$3) RETURNING *' ,
[g,h,i]
);
res.json(newentry.rows[0]);
} catch(err){
console.error(err.message);
}
});