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

MONGOID-5391 - Add #pluck_each, extract out PluckEnumerator #5497

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

johnnyshields
Copy link
Contributor

@johnnyshields johnnyshields commented Oct 5, 2022

Fixes MONGOID-5391

I'd like to humbly request this feature for reconsideration to be merged. A certain Mongoid maintainer of xmas past rejected this on the grounds that there are plans in MONGOID-5411 to make a feature which returns query raw results as a demongoized, field-name-aliased Hash. I fully support doing MONGOID-5411, however its timeline is unspecified (still in "Needs Triage" state), whereas this feature (#pluck_each) is ready to be used today. It yields a tremendous performance gain 🚀 and I've gotten a ton of mileage out of it in my app.

I also feel that this feature is not mutually exclusive functionality-wise with MONGOID-5411. Although the API syntax of MONGOID-5411 is not yet defined, if you just want to pluck a single value, it will look something like .only(:my_field).query_as_hash.each {|result| result[:my_field] } whereas the same in this code can be done here far more tersely as .pluck_each(:my_field) {|value| ... }

Lastly, I think the extraction of PluckEnumerator in this PR is probably a stepping stone toward implementing MONGOID-5411. I'd be happy to add looking at MONGOID-5411 to my queue.

For reference, the previously closed PR including discussion is here: #5332

@johnnyshields
Copy link
Contributor Author

@alexbevi @Neilshweky I really feel this PR should be merged. I find myself using it constantly in my app, it leads to a signficant Ruby performance gain.

@alexbevi
Copy link
Contributor

alexbevi commented Nov 8, 2022

Hi @johnnyshields, this PR (and associated ticket) remains on our shortlist for continued discussion. I hope to have further information for you soon.

@johnnyshields johnnyshields changed the title MONGOID-5391 - Add #pluck_each, extract out PluckEnumerator [READY FOR REVIEW] MONGOID-5391 - Add #pluck_each, extract out PluckEnumerator Feb 10, 2023
@johnnyshields johnnyshields changed the title [READY FOR REVIEW] MONGOID-5391 - Add #pluck_each, extract out PluckEnumerator 🚀 [READY FOR REVIEW] MONGOID-5391 - Add #pluck_each, extract out PluckEnumerator Apr 11, 2023
@johnnyshields
Copy link
Contributor Author

Merged into Mongoid Ultra 🌈

@jamis jamis changed the title 🚀 [READY FOR REVIEW] MONGOID-5391 - Add #pluck_each, extract out PluckEnumerator MONGOID-5391 - Add #pluck_each, extract out PluckEnumerator Apr 15, 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