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

Support OrderBy / Sort for DocumentRepository findOneBy() #2226

Closed
nottoohigh opened this issue Oct 7, 2020 · 3 comments
Closed

Support OrderBy / Sort for DocumentRepository findOneBy() #2226

nottoohigh opened this issue Oct 7, 2020 · 3 comments
Labels
Milestone

Comments

@nottoohigh
Copy link

Feature Request

Q A
New Feature yes
BC Break no
Version Since 2.1

Summary

Unlike findBy, Doctrine\ODM\MongoDB\Repository\DocumentRepository::findOneBy does not currently support $sort as a parameter.

Current

 /**
   * Finds a single document by a set of criteria.
 */
public function findOneBy(array $criteria) : ?object
{
  return $this->getDocumentPersister()->load($criteria);
}

Propose adding support for $sort:

/**
   * Finds a single document by a set of criteria.
*/
public function findOneBy(array $criteria, ?array $sort = null) : ?object
 {
     return $this->getDocumentPersister()->load($criteria, null, [], 0, $sort);
 }
@malarzm
Copy link
Member

malarzm commented Oct 7, 2020

@nottoohigh sounds reasonable :) would you mind sending us a PR with the change and some tests?

@malarzm malarzm added this to the 2.2.0 milestone Oct 7, 2020
@malarzm malarzm added the Feature label Oct 7, 2020
@nottoohigh
Copy link
Author

@malarzm Ok will do as soon as I can. Thank you!

@malarzm
Copy link
Member

malarzm commented Dec 29, 2020

Closing as #2264 was just merged

@malarzm malarzm closed this as completed Dec 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants