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

merge sails hook's model #54

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

merge sails hook's model #54

wants to merge 15 commits into from

Conversation

iamcxa
Copy link

@iamcxa iamcxa commented May 26, 2018

merge sails models again, in order to add hook`s model before init all models.

@coveralls
Copy link

coveralls commented May 29, 2018

Coverage Status

Coverage decreased (-0.04%) to 80.822% when pulling b4c79a1 on MoreAppio:master into b4cc397 on KSDaemon:master.

@KSDaemon
Copy link
Owner

Hi @iamcxa!
Can you explain your changes? Sorry, i do not understand purpose and reasons behind it. Thank you!

@iamcxa
Copy link
Author

iamcxa commented May 31, 2018

hi @KSDaemon, this small modification can load models inside sails hook into Sequelize model.

let's say --- add a project contains controller/model/service folder and make it as a Sails hook, and give it a model definition named User --- so after this modification, sails-hook-sequelize will load this User mode as a normal model into running Sails instance.

p.s. you may need this to load model from hooks in Sails 1.x: https://github.com/bigbn/sails-util-mvcsloader

// then merge sails hook's model before init all models.
if (sails.models) {
const merge = sails.util ? sails.util.merge : _.merge;
const hookModels = sails.models || {};
Copy link
Owner

Choose a reason for hiding this comment

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

Seems that you already checked sails.models in if statement above :)

@KSDaemon
Copy link
Owner

Hi @iamcxa Sorry for so late answer.
Will be great if you'll cover this case with test for 1.0 version!

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.

3 participants