Skip to content

Can only omit discriminator field if _id is also selected #13760

Closed
@cg-julian-taylor

Description

@cg-julian-taylor

Prerequisites

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

Mongoose version

7.4.0

Node.js version

18.6.1

MongoDB server version

4.1.3

Typescript version (if applicable)

No response

Description

When using the mongoose.select() method I can only select to omit discriminator fields if _id is also selected for ommision.

For example:
mongoose.select('-_id -__t') removes the __t field.
mongoose.select('-__t') does not.

This has been attempted using both array and string notation.

this may be related to #13679

Steps to Reproduce

  1. call mongoose.select(['-__t'])
  2. console.log the result to see that __t is not removed from results.

Expected Behavior

__t discriminator field should be removed via select method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugWe've confirmed this is a bug in Mongoose and will fix it.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions