const recipients = await Recipients.findAll({
order: [["createdAt", "DESC"]],
include: [
{
model: RecipientTagMaps,
attributes: ["id"],
include: [{ model: Tags, attributes: ["id", "name"] }],
},
],
limit: limit,
offset: offset,
where: {
isActive: true,
},
});
// RecipientTagMap Table associate:
RecipientTagMap.associate = function (models) {
// associations can be defined here
RecipientTagMap.belongsTo(models.Tags, { foreignKey: "tagId" });
RecipientTagMap.belongsTo(models.Recipients, { foreignKey: "recipientId" });
};