Calling custom method from mongoose schema
<p>I made custom methods with two ways, But not working.  </p>

<p>models</p>

<pre><code>...
// I read it from other stack overflow QA
categorySchema.methods.postChange = function(){
console.log('postChange');
};

// Mongoose reference doc
categorySchema.methods('postChange', function(){
console.log('postChange');
});

var Category = mongoose.model('category',categorySchema);

module.exports = Category;
</code></pre>

<p>routes</p>

<pre><code>...
router.post('/update_cat', upload.single('image_file'), function(req, res){
Category.findOneAndUpdate({name: req.body.name}, {href: req.body.href}, function(err, doc){
    doc.href = req.body.href;
    Category.postChange();
    (err)?res.json(err):res.redirect('./reg_line');
    });
});
</code></pre>

<p>and The error is 'Category.postChange is not a function'.</p>