I have this mongoose post schema.
In validation, is the author
with type UserSchema
, required: true
by default or false?
snippet 1
const PostSchema = new mongoose.Schema({
...
author: UserSchema,
...
});
I want to have something like this where the author
with type UserSchema
is required: false
snippet 2
const PostSchema = new mongoose.Schema({
author: {
type: UserSchema,
required: false
}
});
Is there any other way to do something like this, schema property type another schema to be required true or false? --new to mongoose