-
Notifications
You must be signed in to change notification settings - Fork 7
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
Allow to findBy/findOneBy directly by given object #70
Comments
Just taking a look at your project out of curiosity, why do you have multiple ways of fetching an object?
|
Also, if you can include more details on the issues you opened I'd be happy to help in my spare time |
@mehdibo The main idea is to imitate and respect the interface of the Doctrine's ObjectManager : So, ideally, you could replace Doctrine's EntityManager with the one provided here without changing the way the application works. However, the best practice is still to inject the repository to retrieve its objects. |
For this issue: currently, to retrieve a resource via its nested object, you need to provide the nested object's ID. $repository->findOneBy(['user' => $user->id]); What I want to do is to allow to use it this way $repository->findOneBy(['user' => $user]); |
Ah I see, I don't know if RedisOM is supposed to replace instead of go along with Doctrine but I understand your point. I'd be happy to give it a try this weekend if you didn't already start on it |
No, the plan is not to replace Doctrine, but to be able to use the 2 object mappers interchangeably as needed. |
Got it, let me know if I can start on it |
Nvm why even bother if we can just use the id |
Yes, I think the easiest way is to check if the search criterion is a property that corresponds to an object and if so, retrieve its identifier/index to replace the search parameters. |
$repository->findBy(['user' => $user]);
The text was updated successfully, but these errors were encountered: