Commit e45282c388e99ed24da8666d0d43232c859d3c7b

Authored by 陈亮
1 parent 379112bc

fixed 'only' bugs

lib/Instance.js
... ... @@ -8,6 +8,7 @@ exports.Instance = Instance;
8 8 function Instance(Model, opts) {
9 9 opts = opts || {};
10 10 opts.data = opts.data || {};
  11 + opts.only = opts.only || [];
11 12 opts.extra = opts.extra || {};
12 13 opts.keys = opts.keys || "id";
13 14 opts.changes = (opts.is_new ? Object.keys(opts.data) : []);
... ... @@ -493,7 +494,7 @@ function Instance(Model, opts) {
493 494 } else if (prop && 'defaultValue' in prop) {
494 495 defaultValue = prop.defaultValue;
495 496 }
496   - if(opts.data=={} || key in opts.data)
  497 + if(opts.only.length==0 || key in opts.only)
497 498 {
498 499 setInstanceProperty(key, defaultValue);
499 500  
... ...
lib/Model.js
... ... @@ -418,7 +418,8 @@ function Model(opts) {
418 418 autoFetchLimit : options.autoFetchLimit,
419 419 cascadeRemove : options.cascadeRemove,
420 420 extra : options.extra,
421   - extra_info : options.extra_info
  421 + extra_info : options.extra_info,
  422 + only : options.only
422 423 }, cb);
423 424 }, cb);
424 425 }
... ...