Skip to content

Getters are not called on sub-schemas unless they are a array #12105

@hasezoey

Description

@hasezoey

Prerequisites

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

Mongoose version

6.4.4

Node.js version

18.5.0

MongoDB server version

any

Description

Currently when using getters on a sub-schema and enabling toJSON: { getters: true } on the sub-schema, but not in the top-schema, they wont get added, unless the top-schema defines the nested schema as a array

Steps to Reproduce

Reproduction repository + branch: https://github.com/typegoose/typegoose-testing/tree/gettersNotCalled (follow the README#Setup)

Commit with the base example (not arrays): e013ce3f2d4c5827973753c2ef72f4655e7e9e33
Commit with the arrays: 06764561a634d15e791d391736874928d9b17169

Expected Behavior

To have the behavior consistent across both cases (either dont apply getters or apply getters in both cases)

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