我仍然对Spine JS感到困惑,它真的很聪明很酷。我看到它支持模型关系,但我似乎找不到任何关于has_many :through
关系的信息。
我猜是不可能的,有人知道是不是吗?
晚了五年,但 Spine.js 没有has_many
关系。
引用源码,只有belongsTo、hasOne和hasMany:
Spine.Model.extend({
hasMany: function(name, model, fkey) {
if (fkey == null) {
fkey = (underscore(this.className)) + "_id";
}
return this.prototype[name] = function(value) {
return association(name, model, this, fkey, Collection).refresh(value);
};
},
belongsTo: function(name, model, fkey) {
if (fkey == null) {
fkey = (underscore(singularize(name))) + "_id";
}
this.prototype[name] = function(value) {
return association(name, model, this, fkey, Instance).update(value).find();
};
return this.attributes.push(fkey);
},
hasOne: function(name, model, fkey) {
if (fkey == null) {
fkey = (underscore(this.className)) + "_id";
}
return this.prototype[name] = function(value) {
return association(name, model, this, fkey, Singleton).update(value).find();
};
}
});