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 more methods to Collections #4592

Closed
bakura10 opened this issue Aug 5, 2023 · 3 comments
Closed

Add more methods to Collections #4592

bakura10 opened this issue Aug 5, 2023 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@bakura10
Copy link

bakura10 commented Aug 5, 2023

Hi :),

I am coming from Doctrine world, where collections are having a lot of convenient methods (https://www.doctrine-project.org/projects/doctrine-collections/en/stable/index.html).

The workaround in Mikro-ORM seems to converting first to an array to have access to all JS array related methods. Arrays are more flexible in JS than they are in JS, but maybe exposing those methods to Mikro-ORM collections would reduce the need for this conversion. Here are the one I often use in Doctrine:

  • Reduce
  • Find
  • Find first
  • Exists
  • Filter

Except from this I really love how Mikro-ORM is thought. It feels like Doctrine, but with so many pain points being lifted. That's really a breath of fresh air :)

Thanks!

@bakura10 bakura10 added the enhancement New feature or request label Aug 5, 2023
@B4nan
Copy link
Member

B4nan commented Aug 6, 2023

FYI the collection items are stored in a Set internally, so you need to convert that to an array to be able to use the native array methods. I wanted to add some of those for v6, not sure if we need reduce, and not sure what should be the difference in find and findFirst? Also we already have contains method.

@B4nan B4nan added this to the 6.0 milestone Aug 6, 2023
@rubiin
Copy link
Contributor

rubiin commented Aug 9, 2023

slice and isEmpty seems useful as well. Find and FindFirst seems similar to me unless he meant filter .

@B4nan
Copy link
Member

B4nan commented Aug 10, 2023

Another good candidate would be map().

@B4nan B4nan closed this as completed in 3ba33ac Aug 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants