fix(db-mongodb): 4x and more level deep relationships querying (#12800)

Fixes https://github.com/payloadcms/payload/issues/12721
This commit is contained in:
Sasha
2025-06-13 17:11:13 +03:00
committed by GitHub
parent 7fef589ffa
commit 245a2dee7e
4 changed files with 41 additions and 5 deletions

View File

@@ -245,10 +245,13 @@ export async function buildSearchParam({
value: { $in },
}
} else {
relationshipQuery = {
value: {
_id: { $in },
},
const nextSubPath = pathsToQuery[i + 1]?.path
if (nextSubPath) {
relationshipQuery = {
value: {
[nextSubPath]: { $in },
},
}
}
}
}