Spine.js has_many:通过
问题描述:
我仍然围绕Spine JS,它的真正聪明的很酷的东西。我发现它支持Model Relationships,但我似乎无法找到关于has_many :through
关系的任何信息。Spine.js has_many:通过
我猜它不可能,有人知道它是否是?
答
晚了十年,但Spine.js没有has_many
关系。
引述source code,它只有属于关联,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();
};
}
});