question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

instance.reload() ignores 'include' option

See original GitHub issue

From the docs: “Options that are passed on to Model.find”

But the following does not work (see gist):

https://gist.github.com/matmar10/d460f0fdfa6071dbb2c1


// this works
User.findOne({
  include: [{ as: 'roles', model: UserRole }],
  where: { id: 1 }
}).then(function (user) {
  // has `roles` property OK
  console.log(user);
});

// this does not work
User.findOne({
  where: { id: 1 }
}).then(function (user) {
  user.reload({
    include: [{ as: 'roles', model: UserRole }]
  }).then(function (user) {
    // does NOT have `roles` property
    console.log(user);
  });
});

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:17 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
davesagcommented, Jun 6, 2017

I just tested this and reload with include works fine. I believe this ticket can be closed.

1reaction
matmar10commented, Apr 30, 2015

Shouldn’t it try to honor the include option passed to reload, if it exists? Something like:

Instance.prototype.reload = function(options) {
     return this.Model.find({
           where: where,
           limit: 1,
           include: options.include || this.options.include || null
     }, options).then(function(reload) {
           self.set(reload.dataValues, {raw: true, reset: true});
     }).return(self);
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I unload (reload) a Python module? - Stack Overflow
You can reload a module when it has already been imported by using importlib.reload() : from importlib import reload # Python 3.4+ import ......
Read more >
Health checks for Auto Scaling instances - AWS Documentation
Learn how Amazon EC2 Auto Scaling monitors and responds to health check failures and mitigates against the possibility of false positives.
Read more >
API - ESBuild
Working directory. #Simple options. #Alias. Supported by: Build. This feature lets you substitute one package for another when bundling. The example ...
Read more >
Loading Data - Snowflake Documentation
The COPY INTO <table> command includes a FILES parameter to load files by specific name. Tip. Of the three options for identifying/specifying data...
Read more >
hugo server
It will then live reload any open browser pages and push the latest ... --help help for server --ignoreCache ignores the cache directory ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found