Skip to content

fix(mongodb): Fix mongo count#3541

Merged
daffl merged 5 commits intofeathersjs:dovefrom
DaddyWarbucks:bug/mongo-count
Oct 31, 2024
Merged

fix(mongodb): Fix mongo count#3541
daffl merged 5 commits intofeathersjs:dovefrom
DaddyWarbucks:bug/mongo-count

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 requested a review from daffl October 10, 2024 16:54
@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
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