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

fix(mongodb): Fix mongo count #3541

Merged
merged 5 commits into from
Oct 31, 2024
Merged

Conversation

DaddyWarbucks
Copy link
Member

This PR fixes a bug in the mongo package that caused a miscount when counting documents while using the aggregation pipeline. I recently installed this in a large production app and caught a couple of bugs that the tests had not.

0f1deb6 - Add paginate: false to ensure counting all documents.

e6595b8 - Use the pipeline's $count operator for better performance.

e126577 - Rearrange the pipeline so that it skips and limits before projecting (aka select). Mongo supposedly optimizes the pipeline steps, but its still make sense to me and reads better if we skip/limit before projection.

927f357 - Add 1 missing test from the generic test suite.

Please let me know anything I can do to move this PR through quickly. It is critical bug in a production app and I cannot roll it back easily.

@DaddyWarbucks DaddyWarbucks changed the title Bug/mongo count Bug in mongo count Oct 10, 2024
@DaddyWarbucks DaddyWarbucks changed the title Bug in mongo count Fix mongo count Oct 10, 2024
@DaddyWarbucks
Copy link
Member Author

I was actually able to solve this problem in my own app by just extending the MongoService class with the updates from the PR.

@daffl
Copy link
Member

daffl commented Oct 16, 2024

Thank you! I'll look into why the tests aren't passing today.

@daffl daffl changed the title Fix mongo count fix(mongodb): Fix mongo count Oct 31, 2024
@daffl daffl merged commit 3e95c7d into feathersjs:dove Oct 31, 2024
0 of 2 checks passed
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 this pull request may close these issues.

2 participants