我仍然围绕着Spine JS,这是非常聪明的酷东西。我看到它支持Model Relationships,但我似乎无法找到有关has_many :through
关系的任何信息。
我猜它不可能,有人知道它是不是?
迟到了五年,但Spine.js没有has_many
关系。
引用source code,它只有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();
};
}
});