Commit fbe2fa48f3353346305965c0c2697c4505fb2fe5

Authored by 陈亮
1 parent a610c43c

extendsto bug fix

Showing 1 changed file with 8 additions and 15 deletions
lib/Associations/Extend.js
... ... @@ -143,24 +143,17 @@ function extendInstance(Model, Instance, Driver, association, opts) {
143 143 if (err) {
144 144 return cb(err);
145 145 }
  146 + if (!Extension.isInstance) {
  147 + Extension = new association.model(Extension);
  148 + }
146 149  
147   - Instance[association.delAccessor](function (err) {
148   - if (err) {
149   - return cb(err);
150   - }
151   -
152   - var fields = Object.keys(association.field);
153   -
154   - if (!Extension.isInstance) {
155   - Extension = new association.model(Extension);
156   - }
  150 + var fields = Object.keys(association.field);
157 151  
158   - for (var i = 0; i < Model.id.length; i++) {
159   - Extension[fields[i]] = Instance[Model.id[i]];
160   - }
  152 + for (var i = 0; i < Model.id.length; i++) {
  153 + Extension[fields[i]] = Instance[Model.id[i]];
  154 + }
161 155  
162   - Extension.save(cb);
163   - });
  156 + Extension.save(cb);
164 157 });
165 158 return this;
166 159 },
... ...