Skip to content

Adds EntryRespository#findByIds() #417

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

Draft
wants to merge 1 commit into
base: 4.x
Choose a base branch
from

Conversation

nadinengland
Copy link

@nadinengland nadinengland commented Apr 5, 2025

This PR adds findByIds to EntryRepository. See docs PR

$items = \Statamic\Facades\Entry::findByIds([ 3, 1, 0, 2 ]);

$this->assertInstanceOf(\Statamic\Entries\EntryCollection::class, $items);
$this->assertCount(3, $items);
$this->assertEveryItemIsInstanceOf(\Statamic\Contacts\Entries\Entry::class);
$this->assertEquals([ 3, 1, 2 ], $items->map->id());

Notable functionality:

  • Entries are returned in order of their id's position in the original input argument.
  • Missing IDs are omitted from resultant collection.
  • Entries are first loaded from Blink, if cached, and remainder are loaded from the DB.

Relevancy to core

This is part of a wider piece of work I've start to add a fairly large reduction in DB queries to the statamic/eloquent-driver. The principal idea is to route as many components as possible through the repositories. As I was adding this to the package, parity with the core Repository contract felt good as well: PR on statamic/cms.

@nadinengland nadinengland force-pushed the feature/entries-find-by-ids branch from d3689d9 to 9f6271c Compare April 5, 2025 22:19
@ryanmitchell
Copy link
Contributor

ryanmitchell commented Apr 6, 2025

Thanks for the PR.

The goal of this driver is to match the functionality and contract methods provided by core. So for this to merge the core PR would be to be accepted - il leave that for the core team to decide.

@duncanmcclean
Copy link
Member

Marking this as a draft until the Core PR has been merged.

@duncanmcclean duncanmcclean marked this pull request as draft April 15, 2025 15:15
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.

3 participants