Currently, an optimized DB update (simple data => no delete-and-create-row) does the following: 1. sql UPDATE 2. sql SELECT This PR reduces this further to one single DB call for simple collections: 1. sql UPDATE with RETURNING() This only works for simple collections that do not have any fields that need to be fetched from other tables. If a collection has fields like relationship or blocks, we'll need that separate SELECT call to join in the other tables. In 4.0, we can remove all "complex" fields from the jobs collection and replace them with a JSON field to make use of this optimization --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1210803039809814
120 lines
2.9 KiB
TypeScript
120 lines
2.9 KiB
TypeScript
import type { Config, GlobalConfig } from 'payload'
|
|
|
|
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
|
import { fileURLToPath } from 'node:url'
|
|
import path from 'path'
|
|
|
|
import { devUser } from '../credentials.js'
|
|
import { CustomID } from './collections/CustomID/index.js'
|
|
import { DeepPostsCollection } from './collections/DeepPosts/index.js'
|
|
import { ForceSelect } from './collections/ForceSelect/index.js'
|
|
import { LocalizedPostsCollection } from './collections/LocalizedPosts/index.js'
|
|
import { Pages } from './collections/Pages/index.js'
|
|
import { Points } from './collections/Points/index.js'
|
|
import { PostsCollection } from './collections/Posts/index.js'
|
|
import { UsersCollection } from './collections/Users/index.js'
|
|
import { VersionedPostsCollection } from './collections/VersionedPosts/index.js'
|
|
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
|
|
export const getConfig: () => Partial<Config> = () => ({
|
|
// ...extend config here
|
|
collections: [
|
|
PostsCollection,
|
|
LocalizedPostsCollection,
|
|
VersionedPostsCollection,
|
|
DeepPostsCollection,
|
|
Pages,
|
|
Points,
|
|
ForceSelect,
|
|
{
|
|
slug: 'upload',
|
|
fields: [],
|
|
upload: {
|
|
staticDir: path.resolve(dirname, 'media'),
|
|
},
|
|
},
|
|
{
|
|
slug: 'rels',
|
|
fields: [],
|
|
},
|
|
CustomID,
|
|
UsersCollection,
|
|
],
|
|
globals: [
|
|
{
|
|
slug: 'global-post',
|
|
fields: [
|
|
{
|
|
name: 'text',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'number',
|
|
type: 'number',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: 'force-select-global',
|
|
fields: [
|
|
{
|
|
name: 'text',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'forceSelected',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'array',
|
|
type: 'array',
|
|
fields: [
|
|
{
|
|
name: 'forceSelected',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
forceSelect: { array: { forceSelected: true }, forceSelected: true },
|
|
} satisfies GlobalConfig<'force-select-global'>,
|
|
],
|
|
admin: {
|
|
importMap: {
|
|
baseDir: path.resolve(dirname),
|
|
},
|
|
},
|
|
localization: {
|
|
locales: ['en', 'de'],
|
|
defaultLocale: 'en',
|
|
},
|
|
editor: lexicalEditor({
|
|
features: ({ defaultFeatures }) => [...defaultFeatures],
|
|
}),
|
|
cors: ['http://localhost:3000', 'http://localhost:3001'],
|
|
onInit: async (payload) => {
|
|
await payload.create({
|
|
collection: 'users',
|
|
data: {
|
|
email: devUser.email,
|
|
password: devUser.password,
|
|
},
|
|
})
|
|
|
|
// // Create image
|
|
// const imageFilePath = path.resolve(dirname, '../uploads/image.png')
|
|
// const imageFile = await getFileByPath(imageFilePath)
|
|
|
|
// await payload.create({
|
|
// collection: 'media',
|
|
// data: {},
|
|
// file: imageFile,
|
|
// })
|
|
},
|
|
typescript: {
|
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
|
},
|
|
})
|