Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lean transform doesn't work #12093

Closed
2 tasks done
Hagriel opened this issue Jul 12, 2022 · 3 comments
Closed
2 tasks done

lean transform doesn't work #12093

Hagriel opened this issue Jul 12, 2022 · 3 comments
Assignees
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Milestone

Comments

@Hagriel
Copy link

Hagriel commented Jul 12, 2022

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

MongoDB server version

5.0.9

Description

lean transform doesn't work

Steps to Reproduce

this.favoriteList
      .find({ })
      .lean({
        transform: (doc) => {
          delete doc._id;
          return doc;
        }
      });

Expected Behavior

No response

@IslandRhythms IslandRhythms added the needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity label Jul 13, 2022
@IslandRhythms
Copy link
Collaborator

Can you please show me what you expect the document to look like?

@Hagriel
Copy link
Author

Hagriel commented Jul 15, 2022

@IslandRhythms I expect to see this behavior, but in fact, _id is present

it('allows a transform option for lean on a query gh-10423', async function() {
const testSchema = new mongoose.Schema({
name: String
});
const Test = db.model('gh10423', testSchema);
await Test.create({name: 'foo'});
const result = await Test.findOne().lean({ transform: (doc, ret) => {
delete ret._id;
return ret;
}});
assert.equal(result._id, undefined);
});

@Hagriel
Copy link
Author

Hagriel commented Jul 15, 2022

this example from 0044913

@IslandRhythms IslandRhythms added confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. and removed needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity labels Jul 18, 2022
@IslandRhythms IslandRhythms self-assigned this Jul 18, 2022
@vkarpov15 vkarpov15 added this to the 6.4.6 milestone Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Projects
None yet
Development

No branches or pull requests

3 participants