Skip to content
This repository has been archived by the owner on Jun 30, 2018. It is now read-only.

Select fields on eager loading #778

Closed
lfv89 opened this issue Jun 30, 2013 · 5 comments
Closed

Select fields on eager loading #778

lfv89 opened this issue Jun 30, 2013 · 5 comments
Labels

Comments

@lfv89
Copy link

lfv89 commented Jun 30, 2013

I'm already able to select the fields that will be returned from the ElasticSearch query, but now I would like to be able to select the fields that will be loaded from the database when I pass the load: true option, maybe something like:

tire.search(load: { fields: [:title] })

Can I achieve this behaviour directly trough tire ? Thank you.

@phoet
Copy link
Contributor

phoet commented Jul 5, 2013

@vasconcelloslf when you look at the collection class (https://github.com/karmi/tire/blob/master/lib/tire/results/collection.rb#L156) you can see that everything that you pass to :load will get propagated klass.find(ids, @options[:load])

so when you use the ActiveRecord option :select for find, it should work.

@phoet
Copy link
Contributor

phoet commented Jul 5, 2013

also connected to #762

@lfv89
Copy link
Author

lfv89 commented Jul 5, 2013

@phoet thank's for your attention.

Yep I saw that method, but I don't think that works with MongoID, I just tried Article.find(id, only: :email) and nothing... So I forked tire to make that work with MongoID... Would that be an interesting PR to make ?

@phoet
Copy link
Contributor

phoet commented Jul 7, 2013

@vasconcelloslf can you link the changes in there, so that @karmi can review that?

@karmi
Copy link
Owner

karmi commented Jul 21, 2013

@vasconcelloslf Sorry for the silence. This is also related to #767 and effectively all discussions we're having about having a set of strategies which would allow customizable finders for major ORMs. If you have time, sure link the changes or submit a PR so we can talk around code.

@karmi karmi closed this as completed Oct 2, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants