Files
payload/test/admin/config.ts
2022-07-17 18:02:41 -04:00

63 lines
1.1 KiB
TypeScript

import { mapAsync } from '../../src/utilities/mapAsync';
import { devUser } from '../credentials';
import { buildConfig } from '../buildConfig';
export const slug = 'posts';
export const globalSlug = 'global';
export interface Post {
id: string;
title: string;
description: string;
createdAt: Date;
updatedAt: Date;
}
export default buildConfig({
collections: [
{
slug,
fields: [
{
name: 'title',
type: 'text',
},
{
name: 'description',
type: 'text',
},
],
},
],
globals: [
{
slug: globalSlug,
fields: [
{
name: 'title',
type: 'text',
},
],
},
],
onInit: async (payload) => {
await payload.create({
collection: 'users',
data: {
email: devUser.email,
password: devUser.password,
},
});
await mapAsync([...Array(11)], async () => {
await payload.create({
collection: slug,
data: {
title: 'title',
description: 'description',
},
});
});
},
});