Files
payload/test/database/config.ts
Take Weiland 1510baf46e fix: synchronous transaction errors (#4164)
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
2023-11-20 12:20:42 -05:00

81 lines
1.6 KiB
TypeScript

import { buildConfigWithDefaults } from '../buildConfigWithDefaults'
import { devUser } from '../credentials'
export default buildConfigWithDefaults({
collections: [
{
fields: [
{
name: 'title',
required: true,
type: 'text',
},
{
name: 'throwAfterChange',
defaultValue: false,
hooks: {
afterChange: [
({ value }) => {
if (value) {
throw new Error('throw after change')
}
},
],
},
type: 'checkbox',
},
],
slug: 'posts',
},
{
fields: [
{
name: 'relationship',
relationTo: 'relation-b',
type: 'relationship',
},
{
name: 'richText',
type: 'richText',
},
],
labels: {
plural: 'Relation As',
singular: 'Relation A',
},
slug: 'relation-a',
},
{
fields: [
{
name: 'relationship',
relationTo: 'relation-a',
type: 'relationship',
},
{
name: 'richText',
type: 'richText',
},
],
labels: {
plural: 'Relation Bs',
singular: 'Relation B',
},
slug: 'relation-b',
},
],
onInit: async (payload) => {
await payload.create({
collection: 'users',
data: {
email: devUser.email,
password: devUser.password,
},
})
},
})
export const postDoc = {
title: 'test post',
}