payloadcms/payload

dbName is not working correctly

Closed this issue · 2 comments

Describe the Bug

I need a table in my (not yours) database named something like history but I have histories and I'm using mongoDB

example collection

export const History: CollectionConfig = {
  slug: 'history',
  labels: {
    singular: 'History',
    plural: 'History',
  },
  dbName: 'history',
...

expected tableName with defined dbName property is histroty not histories

Reproduction Steps

create new collection History like above with dbName: string

Which area(s) are affected? (Select all that apply)

db-mongodb

Environment Info

Payload: ^2.0.0
Nodejs: 20.14

sorry that is for v2...

Collection names in MongoDB are automatically pluralized, regardless of dbName. However, you can disable that behaviour with passing autoPluralization: false to the adapter options.

mongooseAdapter({
  url: process.env.MONGODB_URI,
  autoPluralization: false
})