Full-Stack Web Development with Vue.js and Node

(singke) #1
Introducing MongoDB Chapter 3

Remember, we cannot add nested validations in a single Schema like this:


var nameSchema = new Schema({
first_name: String,
last_name: String
});

personSchema = new Schema({
name: {
type: {
first_name: String,
last_name: String
},
required: true
}
});

You can look into Mongoose validations here: http:/​/​mongoosejs.​com/​docs/​validation.


html.


Summary


In this chapter, we covered basic information about MongoDB and its benefits, how to


make CRUD operations and queries in MongoDB, and the basic validations with
Mongoose.


Going further, in the next chapter, we will talk more about the REST APIs and the RESTful


architecture design in our application.

Free download pdf