False positives for modified boolean
If I execute $addToSet and it results in a noop, fiddle will still return true indicating the object was modified.
Looking at my code, the only reason why false should be returned is if you modify a collection with a filter. For example:
var fiddler = fiddle({$inc:{age:1}}, {name:'Craig'});
fiddler({name:"Craig"}); //returns true
fiddler({name:"John"}); //returns false
However, there seems to be a bug where if a set doesn't exist in your target object, fiddle fails to add it. I've opened a new issue for this.
I'll also take a look at the mongodb docs to see where a noop might occur when updating an object.
Oh I see… The true/false response is for filters. In my case, it'd be very useful to also know whether something is noop. Not sure if it aligns with the goals of the lib or I should implement that myself on my end
I think it makes sense to return false if no objects have been modified, so I added it.
By the looks of it, there are only a few operations where this would be useful: $pop, $pull, $rename, and $pullAll. Any other operation should modify an object. Here are a few examples:
var fiddler = fiddle({$rename:{doesNotExist:'cooking'}}),
fiddler2 = fiddle({$pull:{hobbies:'cooking'}});
//returns false
console.log(fiddler({name:"Craig"}));
//returns false
console.log(fiddler2({name:"Craig", hobbies:['traveling']}));
//returns true, removed "cooking"
console.log(fiddler2({name:"Craig", hobbies:['cooking']}));