Javascript 书架js系列

Javascript 书架js系列,javascript,node.js,bookshelf.js,knex.js,Javascript,Node.js,Bookshelf.js,Knex.js,我试着用书架上的藏品还一整张桌子 < TypeError: Cannot read property 'apply' of undefined < at CollectionBase (/projects/twitter/node_modules/bookshelf/lib/base/collection.js:30:18) < at child [as constructor] (/projects/twitter/node_modules/bookshelf

我试着用书架上的藏品还一整张桌子

< TypeError: Cannot read property 'apply' of undefined
<     at CollectionBase (/projects/twitter/node_modules/bookshelf/lib/base/collection.js:30:18)
<     at child [as constructor] (/projects/twitter/node_modules/bookshelf/lib/extend.js:15:14)
<     at new child (/projects/twitter/node_modules/bookshelf/lib/extend.js:15:14)
<     at Function.collection (/projects/twitter/node_modules/bookshelf/lib/bookshelf.js:110:14)
<     at all (/projects/twitter/node_modules/bookshelf/lib/model.js:703:39)
<     at fetchAll (/projects/twitter/node_modules/bookshelf/lib/model.js:768:27)
我尝试使用.fetchAll调用集合和模型

这里是我尝试使用模型的地方

new Users_Data_At_Time().fetchAll()
.then(function (users) {
        console.log(users);
    }).catch(function (error) {
        console.log(error);
    })
我看过几个例子,看起来这是正确的方法,但我仍然会犯这个错误


任何想法或想法都会有巨大的帮助

我想在所有书架上都这样做,但作为一种解决方法,我发现使用knex在书架上的原始查询来选择所有


我不确定这是否是唯一的解决方案如果还有其他解决方案,请让我知道

您的问题可能是文件/模型的命名。表名是数据库中的snake_大小写,所以这显然是好的。但是模型名需要使用pascalcase(也称为大写)。相反的是你的文件,所以它应该是蛇壳

看看这个家伙,特别是最后一段:

您使用的是什么版本的knex?
new Users_Data_At_Time().fetchAll()
.then(function (users) {
        console.log(users);
    }).catch(function (error) {
        console.log(error);
    })