提问人:Ashley Ferns 提问时间:12/6/2022 更新时间:12/6/2022 访问量:693
使用 node js 调用 postgresql 的存储过程
Call stored procedures of postgresql using node js
问:
如何使用 async await 从 nodejs 中的 postgresql 调用存储过程。
这是我的游泳池。
const pool = new pg.Pool({
user: "postgres",
password: "password",
host: "localhost",
database: "mydatabase",
port: 5432
});
这是代码。
app.put("/:id", async(req, res) => {
try {
const { id } = req.params;
const { name, email, hobby } = req.body;
const updateStudent = await pool.proc('updateUser', [name, email, hobby, id]);
res.json("Student was updated")
} catch (err) {
console.error(err.message);
}
})
答: 暂无答案
评论