Skip to content

Feature Request: Separate handling of _id and id fields (as in jenssegers/mongodb) #3398

Open
@szotyi41

Description

@szotyi41

Hi,

In a previous version of our Laravel project, we used the jenssegers/mongodb package, which allowed us to define and use both id and _id fields independently. This was extremely useful for us, as our project was originally built on MySQL and later migrated to MongoDB.

Throughout our codebase (both frontend and backend), we consistently use the id field as a numeric identifier. The old package allowed this without overwriting the MongoDB-native _id field (BSON ObjectId). However, with the current behavior, assigning a value to the id field seems to overwrite the _id, which breaks our expectations and potentially a large part of the application.

We’d really appreciate support for handling the id and _id fields separately again — just like jenssegers/mongodb used to.

Do you have any suggestions or potential workarounds? Refactoring the entire project would be extremely risky and time-consuming.

Thanks in advance!

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