Advertisement
Guest User

blablabla

a guest
Nov 13th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. async function destroyClient(req, res) {
  2.   try {
  3.     await clientService.destroyClient(req.params.user_id);
  4.     res.status(200).json({
  5.       status: true,
  6.       message: { code: "I002", text: "Cliente eliminado con éxito" }
  7.     });
  8.   } catch(err) {
  9.     console.log(err)
  10.     res.status(404).json({
  11.       message: { text: err.message }
  12.         });
  13.   }
  14. }
  15.  
  16. async function destroyClient(user_id) {
  17.     const Client = await models.Client.findOne({ where: { UserId: user_id }});
  18.     if(!Client)
  19.       throw { message : "Cliente no encontrado" }
  20.      
  21.     if(Client.Status == 'something')
  22.       throw { message : "something" }
  23.      
  24.     //No llega si lanza la excepción
  25.     await Client.update({status: false});
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement