2016-05-14 105 views
0

我对这个库(knex)颇为陌生,并且遇到了一个问题,我一直无法在interwebs上找到解决方案。插入显示所有空值

这里是我的Knex连接:

Knex({client: 'pg', connection: config.DB, searchPath:'syp,public', debug: true}) 

这里是我的插入:

Knex('users') 
    .returning('id') 
    .insert(data) 
    .then(function(user) { 
     console.log(user); 
    }, function(err) { 
     console.log(err) 
    }); 

这是我data从上述查询:

{ 
    "first_name": "Kenneth", 
    "last_name": "Stowell", 
    "email": "[email protected]" } 

产生的错误是:

code:"42703" 
file:"parse_target.c" 
length:119 
line:"943" 
name:"error" 
position:"230" 
routine:"checkInsertTargets" 
severity:"ERROR" 

这将使意义,因为调试器显示出下面的SQL:

sql:"insert into "users" ("first_name", "last_name", "email") values (?, ?, ?) returning "id"" 

我希望我只是做一个新手的错误,但我不能为我的生命找出原因。它似乎正在使绑定正确,但从未应用它们。

任何帮助表示赞赏!

回答

0

代码42703是一个postgres错误代码,意味着您试图将数据插入到不存在的列中。