node.js - How i can merge two query in one findAndCount in sequelize? -


need make 1 findandcount() 2 partially different query

userid comes param, , return result depending on whether param buyerid in order or contained sellerid in good

models.order.findandcountall({     distinct: true,     limit,     offset,     where: {       archived: 1,       buyerid: userid,     },     include: [{       model: models.good,       where: { type: 'lineup' },       as: 'good',       include: userinclude     }]   }); 

and

models.order.findandcountall({     distinct: true,     limit,     offset,     where: {       archived: 1,     },     include: [{       model: models.good,       where: { type: 'lineup', sellerid: userid },       as: 'good',       include: userinclude     }]   }); 


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -