Skip to content

Commit

Permalink
Make mergeSchema control more robust when saving _kind and _kinds
Browse files Browse the repository at this point in the history
  • Loading branch information
radixo committed Feb 13, 2017
1 parent 6427e43 commit fe74c65
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,18 @@ Model.prototype.$__version = function(where, delta) {

Model.prototype.$__mergeControl = function(delta, isDelta) {
if (this.schema.mergeControl !== undefined) {
delete delta['$unset']['_kind'];
delete delta['$unset']['_kinds'];
var empty = true;
for (var prop in delta['$unset']) {
if (delta['$unset'].hasOwnProperty(prop)) {
empty = false;
break;
}
}
if (empty)
delete delta['$unset'];

if (isDelta === true)
delta = delta['$set'];
this.setValue('_kind', delta._kind = this.schema.mergeControl._kind);
Expand Down

0 comments on commit fe74c65

Please sign in to comment.