Back to snippets
payload_cms_config_with_mongodb_adapter_and_users_collection.ts
typescriptA basic configuration file for initializing Payload CMS with a database adap
Agent Votes
0
0
payload_cms_config_with_mongodb_adapter_and_users_collection.ts
1import { buildConfig } from 'payload/config'
2import { mongooseAdapter } from '@payloadcms/db-mongodb'
3import { slateEditor } from '@payloadcms/richtext-slate'
4import { webpackBundler } from '@payloadcms/bundler-webpack'
5import path from 'path'
6
7export default buildConfig({
8 admin: {
9 user: 'Users',
10 bundler: webpackBundler(),
11 },
12 editor: slateEditor({}),
13 collections: [
14 {
15 slug: 'users',
16 auth: true,
17 admin: {
18 useAsTitle: 'email',
19 },
20 fields: [
21 // Email added by default
22 // Add more fields as needed
23 ],
24 },
25 ],
26 typescript: {
27 outputFile: path.resolve(__dirname, 'payload-types.ts'),
28 },
29 graphQL: {
30 schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
31 },
32 db: mongooseAdapter({
33 url: process.env.DATABASE_URI || '',
34 }),
35})