Notice: I am new to MEAN and every single part of what makes MEAN up.
In reference to the default configuration of MEANJS and the example module Articles
. I have created another model called Program
.
I know how to add other fields or properties to a model to be able to create and edit accordingly, but I haven't a clue when that new property is a reference to another model.
Without getting into the details of what a Program
is, I want to modify the existing create and edit pages for Articles
to require the user to specify, from a dropdown, which Program
it belongs to.
I have already updated the Articles
schema
var ArticleSchema = new Schema({
created: {
type: Date,
default: Date.now
},
title: {
type: String,
default: '',
trim: true,
required: 'Title cannot be blank'
},
content: {
type: String,
default: '',
trim: true
},
user: {
type: Schema.ObjectId,
ref: 'User'
},
program: {
type: Schema.ObjectId,
ref: 'Program',
required: 'Program cannot be blank'
}
});