mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
RFC - View models as improvement for partial models. #6702
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @scyzoryck on GitHub (Apr 25, 2021).
Hello!
In most of the application that were using tables usually has some fields that are used very rare - for example: User entity contains data about user password / preferences / bio / etc, but in most cases we need only base fields like: username, id or avatar. The solution would be to use partial models in DQL, but it would hydrate data to the same class - what may lead to issues.
What do you think to introduce another type of mapping that would hydrate partial model into another class?
Main rules under it could be:
Usage
Mapping:
Repository usage:
Benefits
Just idea, I'm not sure if it would be useful or terrible to use so I'm really open for any comment :)
Best, Marcin!
@beberlei commented on GitHub (Apr 25, 2021):
Have you seen the 'select new UserViewModel(u.username) from User u' syntax in DQL? I believe it covers your usecase
@scyzoryck commented on GitHub (Apr 26, 2021):
Totally forgot about it! Thanks for help! :)