We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi there!
I've got a schema - let's call it Article. Article can (but isn't required to) have a User embedded within it.
Article
User
class Article extends Document { constructor() { super(); this.title = String; this.user = { type: User, required: false default: null } } } class User extends EmbeddedDocument { constructor() { super(); this.name = { type: String, required: true } } }
Now if I try to save an Article with the user specified as null, I get a validation exception because the name in user is missing.
name
Article.findOneAndUpdate({_id: 1}, { title: "foo", user: null });
ValidationError: Key users.name is required, but got undefined
I want the users.name key to be required, but only when a user is specified.
users.name
Is this possible?
Thanks!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi there!
I've got a schema - let's call it
Article
.Article
can (but isn't required to) have aUser
embedded within it.Now if I try to save an
Article
with the user specified as null, I get a validation exception because thename
in user is missing.I want the
users.name
key to be required, but only when a user is specified.Is this possible?
Thanks!
The text was updated successfully, but these errors were encountered: