We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3f40ee8 commit d8b77dbCopy full SHA for d8b77db
cache.js
@@ -112,7 +112,11 @@ Mongo.Collection.prototype.cache = function(options){
112
childCollection.after.update(function(userId, child, changedFields){
113
if(_.intersection(changedFields, topFields).length){
114
let pickedChild = _.pick(child, childFields)
115
- parentCollection.update({[referenceField]:child._id}, {$set:{[cacheField]:pickedChild}}, {multi:true})
+ // test if the object has been modified
116
+ let previousPickedChild = _.pick(this.previous, childFields);
117
+ if (!_.isEqual(previousPickedChild, pickedChild)){
118
+ parentCollection.update({[referenceField]:child._id}, {$set:{[cacheField]:pickedChild}}, {multi:true})
119
+ }
120
}
121
})
122
0 commit comments