【发布时间】:2015-05-12 18:24:17
【问题描述】:
我对@987654321@ 关联感兴趣。解释:
// Dog.js
module.exports = {
attributes: {
name: {
type: 'string'
},
favorateFoods: {
collection: 'food',
dominant: true
}
}
};
和
// Food.js
module.exports = {
attributes: {
name: {
type: 'string'
},
cost: {
type: 'integer'
}
}
};
换句话说,我希望Dog 与many Food 条目相关联,但至于Food,我不在乎与哪个Dog 相关联。
如果我真的实现了上述方法,不管它是否有效。但是,association 的 table 以非常混乱的方式命名 - 甚至比正常情况更令人困惑;)
dog_favoritefoods__food_favoritefoods_food、id、dog_favoritefoods 和 food_favoritefoods_food。
REST blueprints 函数与 Dog 模型很好,除了时髦的表名外,我没有看到任何“看起来很糟糕”的东西。
所以,问题是,它是否应该以这种方式工作,是否有人看到可能出现问题的东西?
【问题讨论】:
标签: associations sails.js waterline