Load/include association for already existing instance
See original GitHub issueNot sure if this is possible. So I can fetch associations when I am finding object via include
:
models.User.find({ where: { id: 1 }, include: [models.Avatar]).then(function(user) {
user.Avatar // will have avatar object associated with user object.
});
But when I am creating user and use setter to set association, how to get user
object in the end to have user.Avatar
?
user.setAvatar(avatar).then(function(user) {
user.Avatar // not defined?
});
Should I always manually assign object after setting relationship?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:45
- Comments:27 (9 by maintainers)
Top Results From Across the Web
Why can't I seamlessly join my Amazon EC2 Windows ...
Follow these steps to troubleshoot issues when seamlessly joining your Amazon EC2 Windows instance to an AWS Managed Microsoft AD.
Read more >FormStateInterface.php | Drupal 9.0.x
Name Modifiers Type Overrides
FormStateInterface::addBuildInfo public function 2
FormStateInterface::addCleanValueKey public function 2
FormStateInterface::addRebuildInfo public function 2
Read more >Eager Loading - Sequelize
If an association is aliased (using the as option), you must ... you should instead provide an object with two options: model and...
Read more >replace-iam-instance-profile-association - Amazon AWS
You can use this action to change the IAM instance profile that's associated with an instance without having to disassociate the existing IAM...
Read more >Allocate an Amazon Elastic IP and associate it with your ...
Your existing applications will not break because the applications see the IP address they were expecting, even though the back-end EC2 instance has...
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
Please don’t +1 issues. It clutters the thread without adding value to the discussion and spams maintainers with notifications. Use GitHub reactions to upvote features.
I’m shocked that Sequelize doesn’t support this feature. As PHPer before, we benefit this feature provided by Eloquent ORM in Laravel for a long time. I prefer to borrow the
load
API from Eloquent for loading nested associations with the same queries syntax as Sequelize. For example,Comparing to lazy load mentioned above, it would be easier to load all related associations in one call and optimize the SQL queries as much as possible.