This one works fine:
{
name: {
first: { type: String, required: true },
last: { type: String, required: true }
}
}
But this one is not working
{
name: {
required: true,
first: { type: String },
last: { type: String }
}
}
It won't even start:
/Users/albertgao/codes/temp/aaa/node_modules/mongoose/lib/schema.js:751 throw new TypeError(
Invalid schema configuration: \${name}` is not ` + ^TypeError: Invalid schema configuration:
Trueis not a valid type at pathname.required.
How to say that I want name to be required without setting each of its sub-fields?
Thanks