Skip to content

set lean transform at schema level #15583

@y-nk

Description

@y-nk

Prerequisites

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

🚀 Feature Proposal

I have found in issues and PR that .lean() supports a transform: (obj: any) => void function which is used to mutate the object retrieved from db post lean. The problem being that we need to put this function in every .lean() call.

I think it'd be nicer if we could have a leanTransform: (obj: any) => void option saved into the schema to avoid spreading the same transform function (or rather, set as base), similarly to what already exists for toObject and toJSON (schema.options.toObject.transform)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThis issue is a user-facing general improvement that doesn't fix a bug or add a new featurenew featureThis change adds new functionality, like a new method or class

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions