Javascript 是否可以在PostgreSQL中使用knex returning()方法来返回操作表中的所有行
使用Knex.js使用returning方法插入一行后,是否可以返回表中的所有行。我尝试返回(“*”),它只返回受影响的行,而不是表中的所有行。我正在使用POSTGRESQL作为我的数据库。请帮忙 我的代码:Javascript 是否可以在PostgreSQL中使用knex returning()方法来返回操作表中的所有行,javascript,node.js,postgresql,knex.js,Javascript,Node.js,Postgresql,Knex.js,使用Knex.js使用returning方法插入一行后,是否可以返回表中的所有行。我尝试返回(“*”),它只返回受影响的行,而不是表中的所有行。我正在使用POSTGRESQL作为我的数据库。请帮忙 我的代码: app.post('/create', (req, res) => { const { title, content } = req.body; db('projects').insert({ title: title, content: content, a
app.post('/create', (req, res) => {
const { title, content } = req.body;
db('projects').insert({
title: title,
content: content,
authorfirstname: 'John',
authorlastname: 'Doe',
authorid: '12345',
createdat: new Date()
})
.returning('*')
.then( project => {res.json(project)})
.catch( err => res.status(400).json('unable to add project'))
})
不,PostgreSQL不支持这样的东西。您需要先插入表格,然后选择表格中的所有行。可能投票人没有阅读问题。仍然是在2021年,仅返回受影响的行。