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

enhancement: timestamps createdAt property immutable by default #10267

Merged
merged 6 commits into from
Jul 7, 2021

Conversation

IslandRhythms
Copy link
Collaborator

So there is a failing test, however I'm not sure If the test needs to be fixed or my solution needs to be changed. The test is gh-9105

@IslandRhythms IslandRhythms linked an issue May 21, 2021 that may be closed by this pull request
Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say that such change is a breaking change and should not be included in a minor/patch release.
I think it's fine to set createdAt to be immutable by default, but if we choose to go that way, we need to move it to v6.0.

Also, would be neat to offer a global option to set createdAt to false for those who choose to.

@vkarpov15
Copy link
Collaborator

@AbdelrahmanHafez you're right about this being potentially backwards breaking, I'll merge this into 6.0 just to be safe.

Any ideas for syntax re: setting createdAt to false globally? Maybe mongoose.set('timestamps.createdAt', false)?

@AbdelrahmanHafez
Copy link
Collaborator

@vkarpov15
I'd go for mongoose.set('timestamps.createdAt.immutable', false), otherwise it can mislead people to think that this option sets timestamps to not add a createdAt field.

@vkarpov15
Copy link
Collaborator

@AbdelrahmanHafez would having an immutable createdAt break your code?

@AbdelrahmanHafez
Copy link
Collaborator

@vkarpov15
No, but I am anticipating that someone out there is updating the value of createdAt, and it would really make their lives difficult.

We can ship this as an option to set immutable globally on createdAt, to be false by default in v5, then change it to true by default in v6.

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

Successfully merging this pull request may close these issues.

Make createdAt timestamp immutable by default
4 participants