-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
fix: add missing findBy method to MongoEntityManager
#11814
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
Conversation
…m#10264) The findBy() method was missing in MongoEntityManager, causing it to inherit the SQL-based implementation from EntityManager which uses QueryBuilder. Since MongoDB does not support QueryBuilder, this resulted in a Query Builder is not supported by MongoDB error. This fix adds the findBy() method override to use MongoDB's native cursor API instead, following the same pattern as existing methods like findAndCountBy() and findOneBy(). Changes: - Add findBy() method to MongoEntityManager - Add test case in mongo-repository.test.ts - Remove incorrectly placed mongo-query-builder test directory Fixes typeorm#10264
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
findBy method to MongoEntityManager
commit: |
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
gioboa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your help @CHOIJEWON
It looks awesome to me 👏
Description of change
Fixes #10264
The
findBy()method was missing inMongoEntityManager, causing it to inherit the SQL-based implementation fromEntityManagerwhich uses QueryBuilder. Since MongoDB does not support QueryBuilder, this resulted in a "Query Builder is not supported by MongoDB" error.
The Problem
When calling
repository.findBy()on a MongoDB repository:The Solution
Override findBy() in MongoEntityManager to use MongoDB's native cursor API instead of QueryBuilder:
This follows the same pattern as existing methods like findAndCountBy() and findOneBy(), which already work correctly.
Changes:
Testing
All MongoDB tests pass successfully:
Specific test for this fix:
Backward Compatibility
✅ No breaking changes
Related Methods
Note: These methods already work correctly and did not need changes:
Pull-Request Checklist
masterbranchFixes #00000tests/**.test.ts)docs/docs/**.md)Additional Notes
The fix is minimal and follows the established patterns in the codebase. Please let me know if any adjustments are needed!