Skip to content

Commit a63a93a

Browse files
committed
Simplified the approach
1 parent 28b086a commit a63a93a

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

src/RestWrite.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,24 +1589,7 @@ RestWrite.prototype.buildUpdatedObject = function (extraData) {
15891589
const updatedObject = triggers.inflate(extraData, this.originalData);
15901590
Object.keys(this.data).reduce(function (data, key) {
15911591
if (key.indexOf('.') > 0) {
1592-
if (typeof data[key].__op === 'string') {
1593-
updatedObject.set(key, data[key]);
1594-
} else {
1595-
// subdocument key with dot notation { 'x.y': v } => { 'x': { 'y' : v } })
1596-
const splittedKey = key.split('.');
1597-
const parentProp = splittedKey[0];
1598-
let parentVal = updatedObject.get(parentProp);
1599-
if (typeof parentVal !== 'object') {
1600-
parentVal = {};
1601-
}
1602-
let curObj = parentVal;
1603-
for (let i = 1; i < splittedKey.length - 1; i++) {
1604-
if (typeof curObj[splittedKey[i]] === 'undefined') curObj[splittedKey[i]] = {};
1605-
curObj = curObj[splittedKey[i]];
1606-
}
1607-
curObj[splittedKey[splittedKey.length - 1]] = data[key];
1608-
updatedObject.set(parentProp, parentVal);
1609-
}
1592+
updatedObject.set(key, data[key]);
16101593
delete data[key];
16111594
}
16121595
return data;

0 commit comments

Comments
 (0)