Skip to content
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

Default value not set on date when null is passed in. #2438

Closed
avishaan opened this issue Nov 4, 2014 · 1 comment
Closed

Default value not set on date when null is passed in. #2438

avishaan opened this issue Nov 4, 2014 · 1 comment

Comments

@avishaan
Copy link

avishaan commented Nov 4, 2014

When I set the value of a date property whose default is set to Date.now to null, the date is not populated and instead populates as 'null'. I created a quick repo you can run to check this out. There is a lot of overhead because I tried to cut it from my existing code and was in a hurry.

https://github.com/codeHatcher/defaultDateMongooseExample

This is the result, I expected the default date where it says null.
image

Here is the store in the database. I expect null to equal the default date.
screen region 2014-11-03 at 22 45 09

@vkarpov15
Copy link
Collaborator

null is a valid value for a Date property, unless you specify required. Defaults only get set if the value is undefined, not if its falsy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants