- Notifications
You must be signed in to change notification settings - Fork52
Restore default ability to globally set defaults for all models#66
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
coveralls commentedAug 11, 2019
KSDaemon commentedAug 11, 2019
Hi@kinsi55 ! First of all, thanks for contributing! Well, there are a few little bits to make this PR better:
|
kinsi55 commentedAug 11, 2019
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. |
KSDaemon commentedAug 11, 2019
I don't think it's gonna take long! ;) |
kinsi55 commentedAug 11, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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. |
KSDaemon commentedAug 12, 2019
Well, it's possible to use both: sequelize and waterline models at the same time. |
prusswan commentedJul 2, 2020
Found out that Sequelize can do this using the beforeDefine global hook (seesequelize/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
attributesdefined insails.config.modelsare merged into the Models themselves (Except I'm merging the seperate keysails.config.sequelize.modelDefaultsto 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.modelDefaultswill get merged into itWhat kind of change does this PR introduce?
Checklist: