【问题标题】:Waterline : Trying to access a collection string that is not definedWaterline:试图访问未定义的集合字符串
【发布时间】:2015-10-12 23:57:15
【问题描述】:

我在 Sails.js 中使用 Waterline。

我希望有一个 UserInvolvements 。一个事件可以有多个参与参与具有状态。

我的用户类:

module.exports = {

attributes: {
    involvements: {
        collection: 'Involvement',
        via : 'user'
    }
}
};

我的活动课:

module.exports = {

attributes: {
    creator: {
        model: 'User'
    },
    involvements: {
        collection: 'Involvement',
        via: 'event'
    }
}
};

我的参与类:

module.exports = {

attributes: {
    status: {
        type: 'string',
        required: true
    },
    user : {
        model : 'User'
    },
    event : {
        model : 'Event'
    }
}
};

当我尝试启动我的服务器时,我遇到了这个错误:

试图访问未定义的集合字符串。

【问题讨论】:

    标签: node.js orm sails.js waterline


    【解决方案1】:

    尝试将 Sails 更新到较新的版本。我在 Sails 0.11.0 上试过这个,效果很好,所以我猜循环关系可能存在问题。

    npm update sails

    或者如果它是全局安装的:

    sudo npm update -g sails

    【讨论】:

    • 它不会改变任何东西。这可能是我的模型的问题吗?
    • @damienmarchand:模型不应该有问题,因为我尝试过它们并且效果很好。您使用的是什么数据库驱动程序和版本?也请提及sails 版本,最好在您的问题中提及。
    • 对不起。我在其他模型中写了 model : 'string' 而不是 type : 'string'。
    • 啊,这很糟糕。很高兴你发现了它。
    • 忍不住分享一下:我正在摆弄几个模型,最终花了最后半个小时试图在我当前的项目中调试这个确切的问题。最终也破坏了测试数据库。最后是大脸。
    猜你喜欢
    • 2016-07-29
    • 2017-12-11
    • 2011-05-08
    • 1970-01-01
    • 1970-01-01
    • 2019-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多