# NEVER FORGET
Custom validators only works on creating a NEW document.
Document Middleware only works before .save() and .create() DO NOT WORK ON UPDATE(
We can add middlewares before and after a certain event.
In case of a document middleware, this event use to be 'save' event.
In the middleware function itself we have access to the 'this' keyword,
which is pointing at the current being save document.
```javascript
tourSchema.pre('save', function(next) {
this.slug = slugify(this.name, { lower: true });
next();
});
```
This fucntion only runs before .save() and .create() methods.
It will not work for for example findByIdAndReplace method.