【发布时间】:2013-08-07 15:38:08
【问题描述】:
在我的模型中,我已经定义了关系,所以它的外键属性被相关模型所取代。
我有一个想法,从数据库中放弃两个相同的值,例如 relatedId 和 related - 如果我为字段 related 定义模型关系,relatedId 值将保持不变 - 我将可以使用。
是否有可能以某种方式在模型属性的主干关系中使用 collection.where() 方法,这些属性表示相关模型(它们具有对象数据类型)?如果我定义相关的 id - 如下所示 - 它不起作用:
collection.where({
related : 14 // this property contains related model, but not id after backbone initializes, i've also tried to use relatedId key instead - this does not work
})
我非常需要这样的方法,因为我必须通过很多属性找到模型,而且从头开始很难做到:/
能否请教一个方法?
【问题讨论】:
标签: backbone.js backbone-relational