Skip to content

lean() function bug in document's field with Buffer type! #7964

Closed
@DelavariMohsen

Description

@DelavariMohsen

Hi,
I have this model:

_id: mongoose.Types.ObjectId,
name: { type: String, required: true },
mimetype: String,
content: Buffer,

I return content field with this code in Nest js framework:

res.contentType(f.mimetype);
res.send(f.content);

When I find document with this code:

this.files.findById(imageId);

It's OK.
but when I use .lean() function in findById Or findOne and return image to client, Image is not valid image file!

I use:
MongoDb cloud v 4.0.
mongoose: ^5.5.7
@nestjs/mongoose: ^6.1.2,

thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions