Didn't work with async function's try catch
ablipan opened this issue · 1 comments
ablipan commented
(async function() {
try {
// update Store
if (paramStore.id) {
const finded = await Store.findOne(paramStore.id);
_.assign(finded, paramStore);
finded.save();
}else {
// add Store
await Store.create(paramStore);
}
return res.ok();
} catch (err) {
sails.log.error(err);
sails.log.error(err.Errors);
return res.serverError(err);
}
})();
the err.Errors
is undefined.
lykmapipo commented
@ablipan
sails-hook-validation
works only with model static methods only i.e
create()
createEach()
findOrCreate()
findOrCreateEach()
update()
and other static model method that invokeModel.validate()
For instance method consider using sails-model-new
Hope it helps.