Here's a ES6 using Await / Async example:
async deleteProduct(id) {
if (!id) {
return {msg: 'No Id specified..', payload: 1};
}
try {
return !!await products.destroy({
where: {
id: id
}
});
} catch (e) {
return false;
}
}
Please note that I'm using the !!
Bang Bang Operator on the result of the await which will change the result into a Boolean.