node.js - Node : Knex postgres query doesn't trigger unless 'then' is appended

标签 node.js knex.js

我将 Node 与 postgresql 结合使用。我正在尝试对 bd 进行 knex 查询。

如果没有 then() 调用,为什么这个查询不起作用?

knex('test').insert(User1).then();

最佳答案

这是因为框架希望您履行 promise 或调用任何其他提供的 output interfaces

链接 promise 输出是结束查询构建步骤的一种更简洁的方法,请参阅这个小 example ,希望对您有所帮助。

关于node.js - Node : Knex postgres query doesn't trigger unless 'then' is appended,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41372165/

相关文章:

node.js - 回调错误 : TypeError: Cannot read property 'rows' of undefined

node.js - EventEmitter 创建

javascript - CircleCi 有时无法在构建中连接到 Postgres

GraphQL 查询返回 null。但不知道为什么

express - Knex:回滚特定的迁移?

javascript 方法链接 - knex.js

mysql - 我想使用 Sequelize 将 MySQL 中的对象数组存储在单个列中

javascript - 使用 NodeJS 更新全局变量

node.js - 用于聊天应用程序的nodejs的memcache vs redis

javascript - 如何使用 POST 路由从表单中检索数据?