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

Invalid type for Buffer #14902

Closed
2 tasks done
littlegiqnt opened this issue Sep 21, 2024 · 2 comments · Fixed by #14967
Closed
2 tasks done

Invalid type for Buffer #14902

littlegiqnt opened this issue Sep 21, 2024 · 2 comments · Fixed by #14967
Labels
help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary
Milestone

Comments

@littlegiqnt
Copy link

littlegiqnt commented Sep 21, 2024

Prerequisites

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

Mongoose version

8.6.3

Node.js version

doesn't matter

MongoDB server version

doesn't matter

Typescript version (if applicable)

5.6.2

Description

InferSchemaType returns Buffer instead of Binary(from BSON) for Buffer field

Steps to Reproduce

const exampleSchema = new Schema({
    image: { type: Buffer },
});
export type Example = InferSchemaType<typeof exampleSchema>;
// type Example = {
//     image?: Buffer | null | undefined;
// }

Expected Behavior

type Example is:

type Example = {
    image?: Binary | null | undefined;
}

(Binary from BSON)

@vkarpov15
Copy link
Collaborator

That's correct in the sense that image will typically be a Buffer when you access that property. What is your use case for image being a Binary?

@vkarpov15 vkarpov15 added the help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary label Sep 23, 2024
@littlegiqnt
Copy link
Author

Oh sorry i forgot about this issue, it turned out Buffer field will be Binary for leaned document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary
Projects
None yet
2 participants