-
Notifications
You must be signed in to change notification settings - Fork 53
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
Restore default ability to globally set defaults for all models #66
base: master
Are you sure you want to change the base?
Conversation
Hi @kinsi55 ! First of all, thanks for contributing! Well, there are a few little bits to make this PR better:
|
I was just trying to get this out quickly as I've wanted to use it myself. I'll try to add a test for it / extend the readme when I get around to it. If you happen to be interested in doing it you're ofc free to do it :P Dont know when I'd get around to it. |
I don't think it's gonna take long! ;) |
I've a question - when using this hook / Sequelize doesnt it essentially prevent you from using the normal ORM / Waterline alongside? If so I'd just switch it to using sails.config.models instead of the custom key as that makes things more streamlined. |
Well, it's possible to use both: sequelize and waterline models at the same time. |
Found out that Sequelize can do this using the beforeDefine global hook (see sequelize/sequelize#4383) Example:
|
Allows to define global values to set for all models.
Description, Motivation and Context
I found myself where I have a certain column for all of my Models, repeadetly defining them is not really DRY thus I've tried to copy original functionality of Waterlin where
attributes
defined insails.config.models
are merged into the Models themselves (Except I'm merging the seperate keysails.config.sequelize.modelDefaults
to avoid breaking changes).What is the current behavior?
Theres no way to globally define default values for models
What is the new behavior?
Any key not defined in the Model that exists in
sails.config.sequelize.modelDefaults
will get merged into itWhat kind of change does this PR introduce?
Checklist: