Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function destroyClient(req, res) {
- try {
- await clientService.destroyClient(req.params.user_id);
- res.status(200).json({
- status: true,
- message: { code: "I002", text: "Cliente eliminado con éxito" }
- });
- } catch(err) {
- console.log(err)
- res.status(404).json({
- message: { text: err.message }
- });
- }
- }
- async function destroyClient(user_id) {
- const Client = await models.Client.findOne({ where: { UserId: user_id }});
- if(!Client)
- throw { message : "Cliente no encontrado" }
- if(Client.Status == 'something')
- throw { message : "something" }
- //No llega si lanza la excepción
- await Client.update({status: false});
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement