-
-
Notifications
You must be signed in to change notification settings - Fork 526
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
Count unpopulated relations #949
Comments
I don't know if someone is currently working on it, but I would be interested in contributing.
|
I'd say we should cache the value, having Regarding adding elements to the collection, either increment the cached value, or wipe it. Same needs to happen with I guess we should have the method on the |
Do we also take filter into account? |
It should work just fine, as it is using |
Is your feature request related to a problem? Please describe.
When getting a count for a 1:m or m:n relation you first need to populate the relation. This triggers first a
select *
query, requesting all data from the database, creating entities and cluttering the entity map.Describe the solution you'd like
There should be an async
count()
method, maybeloadCount()
that can count the relation without loading all entities. This method should trigger aselect count(*)
query.Additional context
Example: a
Organization
has manyTeam
s. My API can return theOrganization
with a count of the number of teams, but without returning the teams itself.The text was updated successfully, but these errors were encountered: