Skip to content

merge sails hook's model - #54

Open
iamcxa wants to merge 15 commits into
KSDaemon:masterfrom
MoreAppio:master
Open

merge sails hook's model#54
iamcxa wants to merge 15 commits into
KSDaemon:masterfrom
MoreAppio:master

Conversation

@iamcxa

@iamcxa iamcxa commented May 26, 2018

Copy link
Copy Markdown

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

@coveralls

coveralls commented May 29, 2018

Copy link
Copy Markdown

Coverage Status

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

@KSDaemon

Copy link
Copy Markdown
Owner

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

@iamcxa

iamcxa commented May 31, 2018

Copy link
Copy Markdown
Author

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

Comment thread index.js
// 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
Copy Markdown
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
Copy Markdown
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