specify columns to load with relations
See original GitHub issueIs it possible?
new User({id: 2}).fetch({
withRelated: ['account'],
columns: ['id', 'name', 'accountId']
})
I want to load ['id', 'name', 'accountId']
columns from users
table and load ['balance', 'total']
from accounts
table.
Issue Analytics
- State:
- Created 10 years ago
- Comments:22 (7 by maintainers)
Top Results From Across the Web
Laravel Eager Loading - Load only specific columns
I've just updated the original answer, check it now. Basically, if Owner -> Car relationship is set on owners.id -> cars.owner_id , you...
Read more >Eloquent eager loading specific columns - Laracasts
Eloquent eager loading specific columns. I have a Ticket model which and a belongsTo relationship for ticket subject. Copy Code Ticket::with('subject')->get ...
Read more >Eager loading specific columns in a nested relationship
For eager loading a nested relationship you always have to include the primary key or the foreign key to the field list. Wrong....
Read more >Laravel Eager Loading with Selected Columns Example
In this post, we will lean how to select specific columns with eager loading relation in laravel. we can get specific columns using...
Read more >How to Eager Loading Specific Columns in Laravel - PostSrc
To eager load only specific column you can specify the relationship then add the column you want it to load after specifying a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes - I had an undocumented method in knex called
column
which is now documented and working correctly in the just released0.4.7
… I believe that:should take care of it (assuming id is the
idAttribute
of the account table. Give it a shot with the latest Knex and let me know if that works.Hi there, I’m also facing the exact same issue as @howardmann have, I can’t use the select clause on an hasMany relationships, any updates here?