sails-util-mvcsloader icon indicating copy to clipboard operation
sails-util-mvcsloader copied to clipboard

TypeError: Cannot read property 'merge' of undefined using Sails v1

Open nbkhope opened this issue 6 years ago • 1 comments

It seems like sails.util has been removed in Sails v1, so the following lines in libs/models.js no longer work:

var finalModels = sails.util.merge(models, supplements);
sails.hooks.orm.models = sails.util.merge(finalModels || {}, sails.hooks.orm.models || {});
sails.models = sails.util.merge(finalModels || {}, sails.models || {});

Is there an alternative? :\

nbkhope avatar Mar 01 '18 22:03 nbkhope

Turns out the package sails-util included all lodash functions previous to v1:

https://github.com/balderdashy/sails-util/blob/master/index.js

So using _.merge() fixes that issue. It would be nice if this issue was fixed. Why do we have to rely on sails.util if we can just import lodash and _.merge();

or rather simply Object.assign({}, models, supplements) or the spread like { ...models, ...supplements }

nbkhope avatar Mar 01 '18 22:03 nbkhope