我有一个通过bookshelf.js定义的用户模型,如下所示:
const User = bookshelf.model('User', {
tableName: '[thanos.User]'
});
使用bookshelf.js的count()函数:
User.count().then((count) => {
console.log('number of users:', count)
})
我在sqlserver中收到错误,因为bookhelf.js或knex.js通过修改表名而弄乱了我的模式:
select count(*) as [count] from [thanos].[User]
我想知道是否有一种方法可以保持我的表名不变或将其架构定义为其自己的字段。
也在github上打开了一张票:https://github.com/bookshelf/bookshelf/issues/2065
我不知道框架,但是从您看到的我的猜测是,模型定义中的[
和]
可能已被删除。
是否需要在此框架中进行转义-例如类似于`tablename:'[[thanos.user]'?