node.js - 使用sequelize的sql中双冒号的用法是什么?

标签 node.js sequelize.js

我在 node.js 项目中看到了这一点。

sequelize.query("select * from user where user.age=::age",
{替换:{年龄:20}});

为什么他使用双冒号而不是单冒号?

最佳答案

查看 docs 似乎您需要一个冒号。替换可以使用冒号命名,也可以使用问号命名。例如

sequelize.query("select * from user where user.age=:age", {replacements:{age:20}});

或者
sequelize.query("select * from user where user.age=?", {replacements:[20]});

关于node.js - 使用sequelize的sql中双冒号的用法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34740624/

相关文章:

node.js - Nodejs/PostgreSQL sequelize - 如何更新/更改数据库中的模型?

javascript - 按日期升序排序 sequelize 查询的问题

node.js - Sequelize 在两个表上连接两次

node.js - 如何在 node-postgres 的客户端或池之间进行选择

node.js - 在Cosmos DB中使用回送

javascript - 如何创建 Angular Electron 应用程序的 deb 或 exe 文件

node.js - Amazon SES verifyEmailIdentity 未发送电子邮件

sequelize.js - Sequelize -cli : running single seed file is slow

javascript - 当前聚合的 MongoDB Node Driver Count

node.js - Sequelize : Adding a day to the date doesn't work