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>
13 lines
220 B
TypeScript
13 lines
220 B
TypeScript
import type { CollectionConfig } from 'payload'
|
|
|
|
export const FolderPoly2: CollectionConfig = {
|
|
slug: 'folderPoly2',
|
|
fields: [
|
|
{
|
|
name: 'folderPoly2Title',
|
|
type: 'text',
|
|
},
|
|
],
|
|
folders: true,
|
|
}
|