1

我仍然对Spine JS感到困惑,它真的很聪明很酷。我看到它支持模型关系,但我似乎找不到任何关于has_many :through关系的信息。

我猜是不可能的,有人知道是不是吗?

4

1 回答 1

0

晚了五年,但 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();
      };
    }
  });
于 2018-03-01T19:04:20.160 回答