Skip to content

Commit

Permalink
Fix buildQuery for polymorphic relations
Browse files Browse the repository at this point in the history
  • Loading branch information
Convly committed Oct 19, 2020
1 parent 1aac901 commit 8304e3f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/strapi-connector-mongoose/lib/buildQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ const buildDeepQuery = ({ model, filters, search, populate }) => {
$in: ids,
},
},
null,
null
)
.populate(populate);

Expand Down Expand Up @@ -445,12 +445,14 @@ const buildLookupMatch = ({ assoc, assocModel, filters = {} }) => {
},
{
$match: {
$expr: {
$and: defaultMatches.concat(
{ $eq: [`$${assoc.via}.ref`, '$$localId'] },
{ $eq: [`$${assoc.via}.${assoc.filter}`, assoc.alias] }
),
},
$and: defaultMatches.concat({
$expr: {
$and: [
{ $eq: [`$${assoc.via}.ref`, '$$localId'] },
{ $eq: [`$${assoc.via}.${assoc.filter}`, assoc.alias] },
],
},
}),
},
},
];
Expand Down

0 comments on commit 8304e3f

Please sign in to comment.