带有表名的Bookshelf JS混乱

问题描述 投票:0回答:1

我有一个通过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

node.js sql-server knex.js bookshelf.js
1个回答
0
投票

我不知道框架,但是从您看到的我的猜测是,模型定义中的[]可能已被删除。

是否需要在此框架中进行转义-例如类似于`tablename:'[[thanos.user]'?

© www.soinside.com 2019 - 2024. All rights reserved.