Skip to content

Mongo ORM: create() returns _id null when the client uses forceServerObjectId #30517

Open

Description

@wmadden-electric

What a user sees. With forceServerObjectId: true on the Mongo client, the server generates _id, so the ORM does not know it when building the value create() returns. create() returns _id: null (typed as a string); before, it returned no _id at all. Neither is the stored id.

Likely fix. When forceServerObjectId is set, read the inserted document back by a client-known key, or refuse the option with an error that says why; add a test with the option set.

Found by review of the fixes for the Mongo defaults, codecs and Prisma 6 source project's manual QA.

Activity

  1. chrisfonseca8 commented on Oct 2, 2026

    @chrisfonseca8

    Hello! I’d like to contribute to this issue as my first contribution to Prisma ORM.

    I’m planning to investigate why create() returns _id: null when forceServerObjectId: true is enabled and add a regression test.

    Before I start implementing a fix, could you advise which approach you’d prefer: fetching the inserted document to retrieve its server-generated ID or rejecting this option with a clear error?

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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