Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Database name is auto-generated in plural name

default discord avatar
loaialshareelast year
7

Hello,



I am new to Payload CMS. When I create a collection (for example, post), Payload create a database in mongodb in plural form => (posts). I already have a ready-made database named

post

in singular naming and I need Payload to use that database, so Payload cannot detect that because it is creating (posts) automatically. Can anyone please assist on how I can achieve this?



I did the following, but none of them is successful:


* I tried changing the slug to singular name: It keeps enforcing the name to be in plural form.


* I tried adding

labels: {plural: post}

inside the

CollectionConfig

* I tried adding

graphQL: {pluralName: post}

inside the

CollectionConfig

Database name is auto-generated in plural name

  • discord user avatar
    alessiogr
    last year

    Yep, can reproduce that. Looking into this!

  • default discord avatar
    loaialshareelast year
    @360823574644129795

    Sure, I would appreciate it if you can advise. Payload totally fits my requirements, but currently I just have this blocker that I couldn't find a solution for neither from the docs nor from the community help.

  • discord user avatar
    alessiogr
    last year

    So there doesn't seem to be a way to disable that currently. Mongoose automatically does the pluralization of slugs.



    I've just prepared PR which will allow you to configure this:

    https://github.com/payloadcms/payload/pull/2836/files

    Should hopefully make it in one of the next payload releases! Or you could install payload from my PR directly if it's fully blocking you and you are willing to risk that it might not be 100% stable and that the API can change



    In payload 2.0, we can then hopefully disable the automatic pluralization by default.

  • default discord avatar
    loaialshareelast year
    @360823574644129795

    Wow! Thank you very much. Glad to know you're implementing this in your next releases.



    When I created the CMS app, I used

    npx create-payload-app

    and then built my requirements on that CMS. If I want to install Payload with your PR changes, may I know how I can achieve that?

  • discord user avatar
    alessiogr
    last year

    check out

    https://discord.com/channels/967097582721572934/1115437341356593202/1115630826428846162

    so make a fork of my pr branch, then build it, commit the build folder and install it

  • default discord avatar
    loaialshareelast year

    Thank you very much

    @360823574644129795

    ! It is working fine now 🙂



    Hello

    @360823574644129795

    , I have noticed that the branch you made that would fix the pluralization issue for mongodb has been merged (

    https://github.com/payloadcms/payload/pull/3153

    ). I am still using the forked branch you provided to me last time, but want to ask, if I update to the latest version in Payload, will

    autoPluralization

    field be there? Or not yet released?

  • discord user avatar
    alessiogr
    last year

    Hey hey! It won't be in the latest version or any Payload 1.0 version - instead, it will be added in Payload 2.0. Don't worry, the release will be soon 🙂

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.