Hey I have this weird bug:`payload.create` is ret...

default discord avatar
Payload-Bot
last month
1

Hey I have this weird bug:


payload.create

is returning this error:


{
    "error": {
        "index": 0,
        "code": 11000,
        "keyPattern": {
            "username": 1
        },
        "keyValue": {
            "username": null
        }
    }
}

This should happen when there is a conflict between two unique fields. But in my case I have removed the field "username" which was unique. I don't understand where it is getting the "username" from?



Original message from @.janxy - Moved from https://discord.com/channels/967097582721572934/967097582721572937/1165375830621442059 (in #general)
  • default discord avatar
    .janxy
    last month

    The problem was that

    Indexes

    inside MongoDB don't get updated when a collection is removed/updated.

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.