节点postgres插入语法错误
我试图将我的psql安装程序切换到节点,无法获得以下testing查询工作。
PG = require('pg') module.exports = class Postgres extends Backbone.Model initialize: => PG.connect process.env.DATABASE_URL, (error, client) => this.client = client this.sendMessage(1, 2, '3') sendMessage: (from, to, message) => this.client.query('INSERT INTO messages(from, to, content) VALUES($1, $2, $3) RETURNING id', [from, to, message], (error, result) => console.log 'error', error console.log 'result', result )
回应以下错误:
error { [error: syntax error at or near "from"]
我究竟做错了什么?
我不知道是否重要,但这是我的桌子。
我认为Postgres抱怨保留关键字作为列标识符。
你应该尝试在你的查询中双引号,如下所示:
INSERT INTO messages("from", to, content) [...]