Meteor collection hooks


#1

The package readme does not explicitly give examples of usage. I would like to add an after.find action to my collections. This is because I need to change {shown:false} to {shown:false} on my collection properties. How can this be achieved? I also read on a bug/issue with collection hooks with simple-shema.

KM.kmErrors = new Mongo.Collection(null);
KM.kmErrors.hookOptions.after.find = {shown: true};

#2

This should work

KM.kmErrors.after.find(function (userId, selector, options, cursor) {
    cursor.forEach(function(error){ 
        KM.kmErrors.update(error, {$set:{shown:true}}) 
    });
});