payload
payload copied to clipboard
fix(db-mongodb): querying by localized polymorphic relationships using objects
Previously, queries like this didn't work:
const res = await payload.find({
collection: 'polymorphic-relationships',
where: {
polymorphicLocalized: {
equals: {
relationTo: 'movies',
value: movie.id,
},
},
},
})
This was due to the incorrectly passed path to MongoDB without .{locale}
suffix.
Additionally, to MongoDB now we send:
{
polymorphic: {
$eq: {
relationTo: 'movies',
value: 'some-id',
},
},
}
Instead of:
{
and: [
{
'polymorphic.relationTo': {
$eq: 'movies ',
},
},
{
'polymorphic.value': {
$eq: 'some-id ',
},
},
],
}
To match the exact value. This is essential when we do querying by relationships with hasMany: true
and custom IDs that can be repeated.