Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. models.profesional.belongsToMany( models.servicio, {as: 'Servicio' ,foreignKey:'ID_pro',through:'cli_pro_ser'});
  2.  
  3. models.servicio.belongsToMany(models.profesional,{as:'Profesional',foreignKey:'ID_serv',through:'cli_pro_ser'});
  4.  
  5. models.profesional.belongsToMany( models.specialty, {as: 'Especialidad' ,through:'prof_esp'});
  6.  
  7. models.specialty.belongsToMany(models.profesional, {as: 'Prof' ,through:'prof_esp'});
  8.  
  9. models.profesional.belongsTo(models.clinic,{as: 'Clinica',foreignKey:'ID_cli'} );
  10.  
  11. models.clinic.hasMany( models.profesional, {as: 'Profesional' ,foreignKey:'ID_cli'});
  12.  
  13. models.Profesional.findAll({
  14. subQuery: false,
  15. offset: off,
  16. limit: 10,
  17. attributes:['ID','Name','Phone','Photo','Valoracion'],
  18. include: [{model: cli,as:'Clinica',attributes:['Name','Photo'],required:true,
  19. include:[{model: address,as:'Direccion', required:true, attributes:['Street','Number','Latitude','Longitude','Province', 'Location']}]},
  20.  
  21. {model: specialty, as:'Especialidad', attributes:['Name'], through: {attributes: []}},
  22. {model: serv, as:'Servicio',duplicating: false, separate:false}],
  23. where:{Name:{like: '%'+name+'%'},Valoracion:{[Op.gte]:val}},
  24. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement