I am experimenting with specifying nested objects in schema in the following two forms:
1st form:
var UserSchema = Schema({
name: {
first: {
type: String,
required: true
},
last: {
type: String,
required: true
}
}
});
2nd form: (Note that "default" is also honored.)
var UserSchema = Schema({
name: {
type: {
first: {
type: String,
required: true
},
last: {
type: String,
required: true
}
},
default: {
first: 'Foo',
last: 'Bar'
}
}
});
However, with the 2nd form, the "required" validation is being ignored by Mongoose. I understand that "object" is not one of the 7 schema types, but since things other than validation seems to work, I'd expect validation to work as well.
Is this by design?
댓글 없음:
댓글 쓰기