feat: create basic book and authur

This commit is contained in:
Yehoshua Sandler 2025-04-10 16:00:25 -05:00
parent 66c4c17887
commit 828ec41a8b
5 changed files with 114 additions and 9 deletions

View File

@ -1 +1,5 @@
export const importMap = {}
export const importMap = {
}

View File

@ -2,15 +2,37 @@ import type { CollectionConfig } from 'payload'
export const Authors: CollectionConfig = {
slug: 'authors',
admin: {
useAsTitle: 'lf'
},
fields: [
{
name: 'firstName',
name: 'lf',
label: 'last, first name',
type: 'text',
required: true,
unique: true,
index: true,
},
{
name: 'fl',
label: 'First and Last Name',
type: 'text',
},
{
name: 'lastName',
type: 'text',
required: true,
},
name: "role",
type: 'select',
options: [
{
label: 'Author',
value: 'Author'
},
{
label: 'Translator',
value: 'Translator'
},
],
}
],
}

View File

@ -6,10 +6,22 @@ export const Books: CollectionConfig = {
{
name: "books_id", // This is from the import
type: "text",
unique: true,
admin: {
placeholder: "This is only for books that have been imported.",
//readOnly: true,
}
},
{
name: "title",
type: "text",
},
{
name: "authors",
type: "relationship",
relationTo: "authors",
hasMany: true,
maxDepth: 200,
}
],
}

View File

@ -69,6 +69,8 @@ export interface Config {
collections: {
users: User;
media: Media;
books: Book;
authors: Author;
'payload-locked-documents': PayloadLockedDocument;
'payload-preferences': PayloadPreference;
'payload-migrations': PayloadMigration;
@ -77,6 +79,8 @@ export interface Config {
collectionsSelect: {
users: UsersSelect<false> | UsersSelect<true>;
media: MediaSelect<false> | MediaSelect<true>;
books: BooksSelect<false> | BooksSelect<true>;
authors: AuthorsSelect<false> | AuthorsSelect<true>;
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;
@ -149,6 +153,30 @@ export interface Media {
focalX?: number | null;
focalY?: number | null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "books".
*/
export interface Book {
id: number;
books_id?: string | null;
title?: string | null;
authors?: (number | Author)[] | null;
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "authors".
*/
export interface Author {
id: number;
lf: string;
fl?: string | null;
role?: ('Author' | 'Translator') | null;
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-locked-documents".
@ -163,6 +191,14 @@ export interface PayloadLockedDocument {
| ({
relationTo: 'media';
value: number | Media;
} | null)
| ({
relationTo: 'books';
value: number | Book;
} | null)
| ({
relationTo: 'authors';
value: number | Author;
} | null);
globalSlug?: string | null;
user: {
@ -239,6 +275,28 @@ export interface MediaSelect<T extends boolean = true> {
focalX?: T;
focalY?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "books_select".
*/
export interface BooksSelect<T extends boolean = true> {
books_id?: T;
title?: T;
authors?: T;
updatedAt?: T;
createdAt?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "authors_select".
*/
export interface AuthorsSelect<T extends boolean = true> {
lf?: T;
fl?: T;
role?: T;
updatedAt?: T;
createdAt?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-locked-documents_select".

View File

@ -1,6 +1,5 @@
// storage-adapter-import-placeholder
import { postgresAdapter } from '@payloadcms/db-postgres'
import { payloadCloudPlugin } from '@payloadcms/payload-cloud'
import { lexicalEditor } from '@payloadcms/richtext-lexical'
import path from 'path'
import { buildConfig } from 'payload'
@ -9,6 +8,8 @@ import sharp from 'sharp'
import { Users } from './collections/Users'
import { Media } from './collections/Media'
import { Books } from './collections/Books/Books'
import { Authors } from './collections/Authors/Authors'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
@ -19,8 +20,16 @@ export default buildConfig({
importMap: {
baseDir: path.resolve(dirname),
},
dateFormat: 'MM/dd/yyyy',
},
collections: [Users, Media],
cors: [process.env.DOMAIN_NAME || ''],
csrf: [process.env.DOMAIN_NAME || ''],
upload: {
limits: {
fileSize: 5000000, // in bytes
},
},
collections: [Users, Media, Books, Authors],
editor: lexicalEditor(),
secret: process.env.PAYLOAD_SECRET || '',
typescript: {
@ -33,7 +42,7 @@ export default buildConfig({
}),
sharp,
plugins: [
payloadCloudPlugin(),
//payloadCloudPlugin(),
// storage-adapter-placeholder
],
})