Skip to content

Commit

Permalink
feat: Change scope so the filtered resources have all tags included
Browse files Browse the repository at this point in the history
  • Loading branch information
iandebruin98 committed Oct 14, 2024
1 parent 03fb15e commit 0953c95
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions apps/api-server/src/models/Resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,18 +668,14 @@ module.exports = function (db, sequelize, DataTypes) {

selectTags: function (tags) {
return {
include: [
{
model: db.Tag,
attributes: ['id', 'name'],
through: { attributes: [] },
where: {
id: {
[db.Sequelize.Op.in]: tags,
},
},
where: {
id: {
[db.Sequelize.Op.in]: db.Sequelize.literal(`
(SELECT resourceId FROM resource_tags
WHERE tagId IN (${tags.map(tag => `'${tag}'`).join(', ')}))
`),
},
],
},
};
},

Expand Down

0 comments on commit 0953c95

Please sign in to comment.