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

The error caused by Binary when using lean queries still exists in 8.9.2 #15122

Closed
2 tasks done
nikzanda opened this issue Dec 19, 2024 · 1 comment · Fixed by #15123
Closed
2 tasks done

The error caused by Binary when using lean queries still exists in 8.9.2 #15122

nikzanda opened this issue Dec 19, 2024 · 1 comment · Fixed by #15123

Comments

@nikzanda
Copy link

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.9.2

Node.js version

20.10.0

MongoDB server version

6.0.2

Typescript version (if applicable)

5.5.4

Description

In version 8.9.2 of Mongoose, it seems that the error shown in this issue (and this one) is still not resolved.

In the reproduction link the query does not return IParent fields:
Image

Instead, in my project, the last part of the error updates from:

Type 'Binary | null | undefined' is not assignable to type 'Buffer | undefined'.
Type 'null' is not assignable to type 'Buffer | undefined'.

to

Type 'Binary | undefined' is not assignable to type 'Buffer | undefined'.
Type 'Binary' is missing the following properties from type 'Buffer': equals, compare, copy, slice, and 93 more.

Steps to Reproduce

Reproduction link here.

Expected Behavior

No response

@timheerwagen
Copy link

Can confirm, repro:

import mongoose from "mongoose";

type FooBar = {
  value?: string;
};

const TestSchema = new mongoose.Schema<FooBar>({
  value: { type: String },
});

export const FooBarModel = mongoose.model<FooBar>("test", TestSchema);

const main = async () => {
  const item = await FooBarModel.findOne().lean();

  if (!item) return;

  doSomeThing(item);
};

const doSomeThing = (item: FooBar) => {
  console.log(item);
};

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants