Closed nabiltntn closed 8 years ago
collection.before.update(function(userId, doc, fieldNames, modifier, options){
modifier.$set = modifier.$set || {};
modifier.$set.parentProp = {child1:true};
})
Good vibes.
I mimicked what Meteor does in their Allow/Deny API, and lifted their function to get the fieldNames
. I'll be sticking with this for the foreseeable future since it matches an existing similar Meteor API
Hi, When using the before update hook with a nested update like this:
collection.update({_id : 'dddddd'},{$set : {'parentProp.child1' : true}});
fieldNames inside
collection.before.update(function(userId, doc, fieldNames, modifier, options) { });
does not contain full property path : parentProp.child1 but only parentProp