Add Uploads collection

This commit is contained in:
2022-07-25 03:12:31 +00:00
parent 4aae9867ef
commit b323e3b70a
6 changed files with 51 additions and 2 deletions

View File

@@ -19,7 +19,7 @@ const EventTypes: CollectionConfig = {
};
const pickColour = (str) => {
return `hsl(${hashCode(str) % 360}, 100%, 50%)`;
return `hsl(${hashCode(str) % 360}, 100%, 65%)`;
};
doc.backgroundColour = pickColour(doc.name);

View File

@@ -118,6 +118,23 @@ const Events: CollectionConfig = {
name: 'notes',
label: 'Notes',
type: 'textarea'
},
{
name: 'uploads',
label: 'Uploads',
type: 'array',
labels: {
singular: 'file',
plural: 'files'
},
fields: [
{
name: 'upload',
type: 'upload',
relationTo: 'uploads',
required: true
}
]
}
]
};

View File

@@ -0,0 +1,12 @@
import { CollectionConfig } from 'payload/types';
const Uploads: CollectionConfig = {
slug: 'uploads',
upload: {
staticURL: '/uploads',
staticDir: 'uploads'
},
fields: []
};
export default Uploads;

View File

@@ -43,4 +43,21 @@ export interface Event {
end?: string;
location?: string;
notes?: string;
uploads: {
upload: string | Upload;
id?: string;
}[];
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "uploads".
*/
export interface Upload {
id: string;
url?: string;
filename?: string;
mimeType?: string;
filesize?: number;
createdAt: string;
updatedAt: string;
}

View File

@@ -3,6 +3,7 @@ import path from 'path';
import EventTypes from './collections/EventTypes';
import Events from './collections/Events';
import Uploads from './collections/Uploads';
import Users from './collections/Users';
export default buildConfig({
@@ -13,7 +14,8 @@ export default buildConfig({
collections: [
Users,
EventTypes,
Events
Events,
Uploads,
],
typescript: {
outputFile: path.resolve(__dirname, 'payload-types.ts')