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

Hydrating models from results #46

Closed
onbjerg opened this issue Mar 21, 2016 · 2 comments
Closed

Hydrating models from results #46

onbjerg opened this issue Mar 21, 2016 · 2 comments

Comments

@onbjerg
Copy link
Contributor

onbjerg commented Mar 21, 2016

Hi!

Is it possible to retrieve a collection of models with all of the database info, as opposed to just the documents returned by ElasticSearch?

If not, maybe we could add a hydrate method to the results collection?

@onbjerg onbjerg changed the title Retrieving models from documents Hydrating models from results Mar 21, 2016
@onbjerg
Copy link
Contributor Author

onbjerg commented Mar 21, 2016

Here's an example of manual hydration from search results (with some extra code because of #47):

$books = Book::findMany(
    (new Collection(Book::search('moby dick')))->pluck('id')->toArray()
);

If #47 was resolved, the code would be a bit cleaner:

$books = Book::findMany(
    Book::search('moby dick')->pluck('id')->toArray()
);

If we implemented some sort of hydration method, we could probably just do

$books = Book::search('moby dick')->hydrate();

// or

$books = Book::search('moby dick', $hydrate = true);

@timgws
Copy link
Member

timgws commented Apr 7, 2016

Done.

@timgws timgws closed this as completed Apr 7, 2016
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

No branches or pull requests

2 participants