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

feat: Support dynamic default values #527

Merged
merged 1 commit into from
Aug 14, 2023

Conversation

joshuat
Copy link
Collaborator

@joshuat joshuat commented Jul 31, 2023

This introduces the ability for users to provide a function that returns default values rather than an object with static values. This is useful when you're using an _id value other than ObjectId and would like to keep the functionality of automatically generating an _id value on insert.

We continue with the existing behavior of only applying the default value for a path when the path is not included in the insert. This isn't technically a breaking change since all schemas will continue to work as expected.

Closes: #18

@joshuat joshuat force-pushed the josh/feat/dynamic-defaults branch from f1b6bc5 to 78850b6 Compare July 31, 2023 09:46
@joshuat joshuat requested a review from avaly July 31, 2023 09:46
@joshuat joshuat self-assigned this Jul 31, 2023
avaly
avaly previously approved these changes Aug 1, 2023
Copy link
Collaborator

@avaly avaly left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution!

The code and tests look great! I'll try this on our private repo and merge afterwards if no issues pop up.

src/utils.ts Outdated Show resolved Hide resolved
@avaly avaly force-pushed the josh/feat/dynamic-defaults branch from 9310a49 to 2c127e5 Compare August 14, 2023 10:31
@avaly avaly enabled auto-merge (squash) August 14, 2023 10:32
@avaly avaly merged commit 34d0434 into plexinc:main Aug 14, 2023
6 checks passed
@avaly avaly mentioned this pull request Mar 12, 2024
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.

Feature Request: Dynamic Defaults
2 participants