setanalasan48

Untitled

Nov 21st, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Get History
  2. exports.getAllHistory = async (req, res) => {
  3.   const {
  4.     id
  5.   } = req.params;
  6.  
  7.   Transactions.belongsTo(Services,{foreignKey: 'id_services'})
  8.   Services.hasMany(Transactions,{foreignKey: 'id'})
  9.  
  10.  const historyTransactions= await Transactions.findAll({  
  11.    include:[{
  12.     model:Services,
  13.     require:true
  14.    }] ,
  15.    where:{
  16.      id_user:id
  17.    }
  18.   })
  19.  
  20.   if(historyTransactions){
  21.     res.json({
  22.       message:'Succes Get Data',
  23.       data:historyTransactions
  24.     })
  25.   }else{
  26.     res.json({
  27.       message:'empty data'
  28.     })
  29.   }
  30.  
  31. }
Add Comment
Please, Sign In to add comment