weixin_39717598 2020-11-22 01:02
浏览 0

Add support for using the entire ids property as the primary key of a model.

From ada....com on November 09, 2012 12:45:06

Branch name: adamvy-review Purpose of code changes on this branch: Added support for using all entries of the ids property for the primary key of a Model.

After the review, I'll merge this branch into: master

Original issue: http://code.google.com/p/foam-framework/issues/detail?id=19

该提问来源于开源项目:foam-framework/foam

  • 写回答

5条回答 默认 最新

  • weixin_39717598 2020-11-22 01:02
    关注

    From kgrgr....com on November 09, 2012 09:58:16

    Move the Array.isArray() checks outside of the getter and setter and then have two sets of getters and setters. This lets you perform the check only once at compile time rather than once every time the getter or setter is called.

    I like your use of map in the getter, but you could also do something similar in the setter:

    primaryKey.map(function(key, i) { this[key] = val[i]; });

    (the second argument to the map function is the index (and the third is the array))

    Cc: ada....com

    评论

报告相同问题?