sails-util-mvcsloader
sails-util-mvcsloader copied to clipboard
TypeError: Cannot read property 'merge' of undefined using Sails v1
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? :\
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 }