|
7 | 7 | isNullOrUndefined, |
8 | 8 | ensureArray, |
9 | 9 | transformFetchOptions, |
| 10 | + setValue, |
| 11 | + findValue, |
10 | 12 | } = require('./utils'); |
11 | 13 |
|
12 | 14 | const RESERVED_KEYS = ['objectId', 'createdAt', 'updatedAt']; |
@@ -525,9 +527,10 @@ module.exports = function(AV) { |
525 | 527 | _applyOpSet: function(opSet, target) { |
526 | 528 | var self = this; |
527 | 529 | AV._objectEach(opSet, function(change, key) { |
528 | | - target[key] = change._estimate(target[key], self, key); |
529 | | - if (target[key] === AV.Op._UNSET) { |
530 | | - delete target[key]; |
| 530 | + const [value, actualTarget, actualKey] = findValue(target, key); |
| 531 | + setValue(target, key, change._estimate(value, self, key)); |
| 532 | + if (actualTarget && actualTarget[actualKey] === AV.Op._UNSET) { |
| 533 | + delete actualTarget[actualKey]; |
531 | 534 | } |
532 | 535 | }); |
533 | 536 | }, |
@@ -569,9 +572,10 @@ module.exports = function(AV) { |
569 | 572 | AV._arrayEach(this._opSetQueue, function(opSet) { |
570 | 573 | var op = opSet[key]; |
571 | 574 | if (op) { |
572 | | - self.attributes[key] = op._estimate(self.attributes[key], self, key); |
573 | | - if (self.attributes[key] === AV.Op._UNSET) { |
574 | | - delete self.attributes[key]; |
| 575 | + const [value, actualTarget, actualKey] = findValue(self.attributes, key); |
| 576 | + setValue(self.attributes, key, op._estimate(value, self, key)); |
| 577 | + if (actualTarget && actualTarget[actualKey] === AV.Op._UNSET) { |
| 578 | + delete actualTarget[actualKey]; |
575 | 579 | } else { |
576 | 580 | self._resetCacheForKey(key); |
577 | 581 | } |
|
0 commit comments