Files
payloadcms/test/e2e/collections/config.ts
2022-07-14 16:16:16 -07:00

49 lines
920 B
TypeScript

import { mapAsync } from '../../../src/utilities/mapAsync';
import { devUser } from '../../credentials';
import { buildConfig } from '../buildConfig';
export const slug = 'posts';
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',
},
],
}],
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',
},
});
});
},
});