Skip to content

Commit

Permalink
Fix initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
jledentu committed Dec 20, 2020
1 parent 3199570 commit 8e912a4
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions lib/index.js
Expand Up @@ -42,7 +42,7 @@ module.exports = function(sails) {
let attr = model.attributes[name];
if (attr.type === 'slug' && attr.from) {
attr.type = 'string';

model.beforeCreate = ((previousBeforeCreate, from, blacklist) =>
function(values, cb) {
const slugName = slug(values[from], {
Expand Down Expand Up @@ -80,18 +80,14 @@ module.exports = function(sails) {
},
},

initialize(done) {
sails.after('hook:moduleloader:loaded', () => {
const originalLoadModels = sails.modules.loadModels;
sails.modules.loadModels = function(cb) {
originalLoadModels((error, models) => {
patchModels(models);
console.log(models);
cb(error, models);
done();
});
};
});
configure() {
const originalLoadModels = sails.hooks.moduleloader.loadModels;
sails.hooks.moduleloader.loadModels = function(cb) {
originalLoadModels((error, models) => {
patchModels(models);
cb(error, models);
});
};
},
};
};

0 comments on commit 8e912a4

Please sign in to comment.