Setting up the Express components

Let's begin with the Express part of the module. First, you'll create a Mongoose model that will be used to save and validate your articles. Then, you'll move on to the Express controller that will deal with the business logic of your module. Finally, you'll wire the Express routes to produce a RESTful API for your controller methods. We'll begin with the Mongoose model.

Creating the Mongoose model

The Mongoose model will consist of four simple properties that will represent our Article entity. Let's begin by creating the Mongoose model file in the app/models folder, create a new file named article.server.model.js that contains the following code snippet:

var mongoose = require('mongoose'), Schema = mongoose.Schema; ...

Get Web Application Development with MEAN now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.