Chapter 11. Plugins – Re-using Code
In this chapter, we will introduce the Mongoose plugin architecture and see how we can use it to create modular re-usable code. We will look at the syntax and how to write them and include them in our code.
By the end of this chapter, you will understand how to create and use Mongoose plugins. You will also know where to go to find existing plugins that others have written, and contribute to the community by submitting your own. You will have created some plugins in the MongoosePM application.
Reusable schema plugins
If we look at our schemas, we can see some common elements that we are repeating. For example, each of our schemas has an identical
modifiedOn path, and our project and task schemas each have identical ...