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

[BUG] - Using .lean() doesn't transform nested populate #903

Open
SK-FComputer opened this issue Dec 7, 2023 · 2 comments
Open

[BUG] - Using .lean() doesn't transform nested populate #903

SK-FComputer opened this issue Dec 7, 2023 · 2 comments
Labels
bug Something isn't working not a typegoose issue This is not a typegoose issue / This pr addresses something that shouldnt be in typegoose

Comments

@SK-FComputer
Copy link

Versions

  • System: linux
  • NodeJS: 16.18.1
  • Typescript: 5.3.2
  • Compiler / Transpiler: tsc / ts-node
  • Typegoose(NPM): 11.7.1
  • mongoose: 7.6.6
  • mongodb: 6.0.11

What is the Problem?

Just to clarify from a start, yes i know this might be wrong usage:
Using this code to populate paths doesn't get transformed when populating paths with .lean() option.

Code Example

Structure:
User.debtor[REF].discounts[ARRAY].discount[REF]

  1. Get's populated, but not transformed
UserModel.findById(id)
    .populate({
  	  path: 'debtor',
  	  populate: {
  		  path: 'discounts',
  		  populate: {
  			  path: 'discount',
  		  },
  	  },
    }).lean();
  1. This works as expected (Populated + transformed):
UserModel.findById(id)
	.populate({
		path: 'debtor',
		populate: {
			path: 'discounts.discount',
		},
	}).lean();

Do you know why it happens?

no, but I'm guessing the code to populate supports the option while the code to transform/lean doesn't?


I can't upgrade to latest versions at current time, so I can't confirm but still suspect this is an issue there.

@SK-FComputer SK-FComputer added the bug Something isn't working label Dec 7, 2023
@hasezoey
Copy link
Member

hasezoey commented Dec 7, 2023

if your problem is about what .populate does at runtime, then you need to report this issue to mongoose instead of typegoose, because typegoose has no part in this (typegoose only "compiles" the class into a mongoose schema and model)

@hasezoey hasezoey added the not a typegoose issue This is not a typegoose issue / This pr addresses something that shouldnt be in typegoose label Dec 7, 2023
@SK-FComputer
Copy link
Author

More so about what .lean does, populate works as expected. Or at least as in both code examples
But I guess the issue is still with mongoose, I'll post a bug report there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working not a typegoose issue This is not a typegoose issue / This pr addresses something that shouldnt be in typegoose
Projects
None yet
Development

No branches or pull requests

2 participants