官方文档上默认的查询的key 是id , 而且查询条件和更改的colums放在一起 我觉得很奇怪,而且我试过了 如果一个表的主键是user_id 不是id 时就会报错 请各位指教
回复 (4)
D
同样遇到过这个问题,于是翻了 source :
proto.update = function* (table, row, options) {
// ......
if (!options.where) {
if (!('id' in row)) {
throw new Error('Can\'t not auto detect update condition, please set options.where, or make sure obj.id exists');
}
options.where = {
id: row.id,
};
}
// ......
可以看到,update 时主键必须指定且只能为 id
D
哈哈哈,顺便还发现 error message 写错了:Can't not .... (笑)
L
引用 dreamswhite哈哈哈,顺便还发现 error message 写错了:Can't not .... (笑)
@dreamswhite 哈哈😄,我已经用了query的方法直接写sql语句,他这个封装真的不是很好用
A
欢迎 PR
参与回复
登录后即可参与回复。登录