Files
payload/test/_community/collections/Posts/index.ts
2024-03-19 00:59:56 -04:00

76 lines
1.3 KiB
TypeScript

import type { CollectionConfig } from 'payload/types'
import { mediaSlug } from '../Media/index.js'
export const postsSlug = 'posts'
export const PostsCollection: CollectionConfig = {
slug: postsSlug,
admin: {
useAsTitle: 'text',
},
fields: [
{
name: 'text',
type: 'text',
},
{
type: 'row',
fields: [],
},
{
name: 'richText',
type: 'richText',
},
{
name: 'relationship',
type: 'relationship',
// filterOptions: ({ id }) => {
// return {
// where: [
// {
// id: {
// not_equals: id,
// },
// },
// ],
// }
// },
relationTo: ['posts'],
},
{
name: 'associatedMedia',
type: 'upload',
access: {
create: () => true,
update: () => false,
},
relationTo: mediaSlug,
},
{
name: 'blocksField',
type: 'blocks',
blocks: [
{
slug: 'block1',
fields: [
{
name: 'group1',
type: 'group',
fields: [
{
name: 'group1Text',
type: 'text',
},
],
},
],
},
],
},
],
versions: {
drafts: true,
},
}