i trying update field on query hook. example:
var myschema = new schema({ name: string, querycount: {type: number, default:0} }); i want increment , update querycount field on each find or findone query.
myschema.post('find', function (doc) { // here magic }); i have tried few things no success far. can achieve in model or have in controller?
what want post init hook
myschema.post('init', function (doc) { doc.querycount++; doc.save(); });
Comments
Post a Comment