Skip to content

Error "_id is already taken" when trying to update user.... #145

@sagarwal10

Description

@sagarwal10

I tried the POSTMAN api to update the user's email address via the PUT request but I get the following error
saying the _id already exists:

=====================================
{
"errors": {
"_id": "is already taken"
}
}

I believe the error is being triggered by the uniqueValidator(). I read on stackoverflow that if one uses
findOneAndUpdate() instead then the uniqueValidator is not invoked. However when I tried this I got an
error that one cannot modify the _id of an existing entry in the database (even though the _id is the same
value as before).

Anybody else encounter this error? Please advise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions