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

Mention model name in missing virtual option in getModelsMapForPopulate #13406

Closed
2 tasks done
hasezoey opened this issue May 17, 2023 · 0 comments · Fixed by #13408
Closed
2 tasks done

Mention model name in missing virtual option in getModelsMapForPopulate #13406

hasezoey opened this issue May 17, 2023 · 0 comments · Fixed by #13408
Labels
developer-experience This issue improves error messages, debugging, or reporting
Milestone

Comments

@hasezoey
Copy link
Collaborator

Prerequisites

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

Issue

Currently the error below does not mention the model name, and the stacktrace is all just node_modules/mongoose, making it hard to find which model is causing a problem

return new MongooseError('If you are populating a virtual, you must set the ' +

example:

/mnt/projects/nodejs/typegoose-testing/node_modules/mongoose/lib/helpers/populate/getModelsMapForPopulate.js:392
      return new MongooseError('If you are populating a virtual, you must set the ' +
             ^

MongooseError: If you are populating a virtual, you must set the localField and foreignField options
    at _virtualPopulate (/mnt/projects/nodejs/typegoose-testing/node_modules/mongoose/lib/helpers/populate/getModelsMapForPopulate.js:392:14)
    at getModelsMapForPopulate (/mnt/projects/nodejs/typegoose-testing/node_modules/mongoose/lib/helpers/populate/getModelsMapForPopulate.js:42:12)
    at populate (/mnt/projects/nodejs/typegoose-testing/node_modules/mongoose/lib/model.js:4186:21)
    at _populate (/mnt/projects/nodejs/typegoose-testing/node_modules/mongoose/lib/model.js:4146:5)
    at /mnt/projects/nodejs/typegoose-testing/node_modules/mongoose/lib/model.js:4118:5
    at new Promise (<anonymous>)
    at Function.populate (/mnt/projects/nodejs/typegoose-testing/node_modules/mongoose/lib/model.js:4117:10)
    at /mnt/projects/nodejs/typegoose-testing/node_modules/mongoose/lib/query.js:2465:11
    at /mnt/projects/nodejs/typegoose-testing/node_modules/mongoose/lib/query.js:3080:21
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
@hasezoey hasezoey added the developer-experience This issue improves error messages, debugging, or reporting label May 17, 2023
@hasezoey hasezoey added this to the 7.1.2 milestone May 17, 2023
hasezoey added a commit to hasezoey/mongoose that referenced this issue May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
developer-experience This issue improves error messages, debugging, or reporting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant