New issue
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
feat(model): add applyDefaults()
helper that allows applying defaults to document or POJO
#12057
Conversation
…ts to document or POJO Re: #11945
…c place (for docs)
This is to make it more obvious to what this parameter does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome, thanks!
Is there a way where we can use applyDefaultToPOJO
inside applyDefaults
? I'm concerned that on the long run we'll add some rules to applyDefaults
that won't be applied to applyDefaultsToPojo
and they'll go out of sync. This won't happen if applyDefaults
relies on applyDefaultsToPojo
What do you think? @vkarpov15
@AbdelrahmanHafez I would love to make it so that we follow the same code path for both documents and POJOs. But unfortunately there's a lot of little edge cases. For example, for documents we need to set paths to |
Use ServerDescription methods for getting server host and port instead of parsing hostname, which did not work properly. Closes #12063
…ce" to "Model.mapReduce" also adds a description
Re: #11945
Summary
Model.applyDefaults(doc)
applies the defaults specified in the model's schema todoc
.doc
can be either a document or a POJO/lean document.Couple of use cases:
defaults: false
, because you want to apply defaults later after some other logic.Examples