Adding model validation
Mongoose allows you to add additional properties to a model that define how it can be saved or updated.
Let's go ahead and create a second model that we'll be using in the API: a user.
We'll pop that directly underneath the Item
model definition. Let's create a variable User
and again call the model
method of the mongoose
object.
Click to load comments...