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

Add pluck method #422

Merged
merged 1 commit into from
Apr 4, 2020
Merged

Add pluck method #422

merged 1 commit into from
Apr 4, 2020

Conversation

andrykonchin
Copy link
Member

@andrykonchin andrykonchin commented Apr 4, 2020

Implemented a new method Model.pluck which works similar to ActiveRecord's pluck method.

It's like the .project method but returns array of attributes instead of models so should be cheaper and faster. Another difference is that .project returns a chain but .pluck a final collection.

Examples:

User.pluck(:first_name) # => ['Alice', 'Bob', ...]
User.pluck(:first_name, :last_name) # => [['Alice', 'Cooper'], ['Bob', 'Marley'], ...]

@andrykonchin andrykonchin merged commit 79504b0 into master Apr 4, 2020
@andrykonchin andrykonchin deleted the add-plick-method branch April 4, 2020 15:22
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.

None yet

1 participant