我有表“客户”
和表“对话”
我对javascript很陌生。目前,我尝试使用 knex + bookshelf(带有繁琐驱动程序的 SQL 服务器数据库)来加入这两个表。我将这两个表分成两个模型并从路由器调用它(我使用 Node js)。
对话.js
customer: function() { return this.belongsTo('Customer','uniqueid'); }
客户.js
conversation: function(){ return this.hasMany('Conversation','customer_id'); }
当我尝试加入表格时
Customer.fetchAll({withRelated:['conversation'], debug: true}).then(function(data{
console.log('data : '+data);
});
不幸的是,我总是得到错误:
未处理的拒绝请求错误:nvarchar 值“238998679919674”的转换溢出了一个 int 列。
我很好奇错误来自哪里?因为列的类型是 nvarchar,而不是 int。
调试的结果是
{ method: 'select',
options: {},
timeout: false,
cancelOnTimeout: false,
bindings: [],
__knexQueryUid: '7befdc84-c66c-4278-b88c-d53a306c36db',
sql: 'select [customers].* from [customers]' }
GET /ticket/list 500 16 - 21.899 ms
{ method: 'select',
options: {},
timeout: false,
cancelOnTimeout: false,
bindings:
[ 1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50 ],
__knexQueryUid: '29ca9239-b7af-4765-95b1-836ed2c570ce',
sql: 'select [conversations].* from [conversations] where [conversations].[customer_id] in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' }