Following Joe Eames tutorial, "Building AngularJS and Node.js Apps with the MEAN Stack" at Pluralsight, he demonstrates an example of a Mongoose Schema with document fields that are required, as follows:
var courseSchema = mongoose.Schema({
title: {type:String, required:'{PATH} is required!'},
featured: {type:Boolean, required:'{PATH} is required!'},
published: {type:Date, required:'{PATH} is required!'},
tags: [String]
});
I have created my own schema, with a sub-document that works:
......
skin : {styleNum : String, headerLogo: String},
......
However, I want the fields to be required and the subdocument is not an array (in Entity Framework it would be akin to an association, not a collection), so this is wrong:
......
skin : [
{styleNum : String, required:'{PATH} is required!'},
{headerLogo: String, required:'{PATH} is required!'}
]
......
What would be the correct syntax for creating an 'Entity Framework"-like association in a Mongoose Schema where both fields are required?