feat: polymorphic join querying by fields that don't exist in every collection (#12648)
This PR makes it possible to do polymorphic join querying by fields that
don't exist in all collections specified in `field.collection`, for
example:
```
const result = await payload.find({
collection: 'payload-folders',
joins: {
documentsAndFolders: {
where: {
and: [
{
relationTo: {
in: ['folderPoly1', 'folderPoly2'],
},
},
{
folderPoly2Title: { // this field exists only in the folderPoly2 collection, before it'd throw a query error.
equals: 'Poly 2 Title',
},
},
],
},
},
},
})
```
---------
Co-authored-by: Jarrod Flesch <jarrodmflesch@gmail.com>
This commit is contained in:
@@ -4,6 +4,8 @@ import path from 'path'
|
||||
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
|
||||
import { Categories } from './collections/Categories.js'
|
||||
import { CategoriesVersions } from './collections/CategoriesVersions.js'
|
||||
import { FolderPoly1 } from './collections/FolderPoly1.js'
|
||||
import { FolderPoly2 } from './collections/FolderPoly2.js'
|
||||
import { HiddenPosts } from './collections/HiddenPosts.js'
|
||||
import { Posts } from './collections/Posts.js'
|
||||
import { SelfJoins } from './collections/SelfJoins.js'
|
||||
@@ -337,6 +339,8 @@ export default buildConfigWithDefaults({
|
||||
},
|
||||
],
|
||||
},
|
||||
FolderPoly1,
|
||||
FolderPoly2,
|
||||
],
|
||||
localization: {
|
||||
locales: [
|
||||
|
||||
Reference in New Issue
Block a user