Skip to content

Schema versionKey false does not remove __v from typescript type #15424

Open
@gregg-cbs

Description

@gregg-cbs

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

8.10.0

Node.js version

22.8.0

MongoDB server version

6.12.0

Typescript version (if applicable)

5.4.5

Description

When omiting the versionKey from a schema the __v property is still present in typescript.

Image

Steps to Reproduce

Create a schema and notice the __v property still present after omitting versionKey

const documentSchema = new Schema({}, {strict: false, versionKey: false})
export const DB = mongoose.model("cart", documentSchema, "cart");
const b = await DB.findOne().lean()
b?.__v

Expected Behavior

Expect __v to be removed from typescript types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    typescriptTypes or Types-test related issue / Pull Request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions