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.

Exclude associations from autoFetch

See original GitHub issue

autoFetch is a really cool feature. But it can prove to be unpractical when returning far too much data, that is actually not needed.

Imagine having users and messages grouped into conversations with other participating users. Writing

user.getConversations({ autoFetch: true }, function (err, conversations) {
    // conersation.participants
    // conversation.messages
});

is really convenient, but it will return all messages for all conversations, even when they are not needed to display a overview of available conversations.

I would like to propose the following syntax:

user.getConversations({ autoFetch: [ 'participants' ] }, function (err, conversations) {
    // conversation.participants
});

The autoFetch will only include the associations given. If autoFetch is set to true, then just fetch all associations. If it is an array, only fetch the ones specified.

Issue Analytics

  • State:open
  • Created 10 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
dresendecommented, Sep 24, 2013

This is a great idea, will try to do it when I have some time.

0reactions
lawrencebensaidcommented, Jun 5, 2021

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

autofetch-2up.pdf - UT Computer Science
presents AUTOFETCH, a technique for automatically generating prefetch ... prefetch to ignore associations that are likely to be cached.
Read more >
How to exclude association belongs-to-many from an instance ...
I'm trying to exclude a junction model from a query with the association of a model, this is how they are associated:
Read more >
Can't exclude association's fields from select statement in ...
I have the following code (simplified): var group = sequelize.define("group", { id: {type: DataTypes.INTEGER, autoIncrement: false ...
Read more >
User and Workspace Settings - Visual Studio Code
The first time you open a workspace that defines any of these settings, VS Code will warn you and then always ignore the...
Read more >
User and Workspace Settings - vscode-docs
Search Configuration - file exclude filters; Git Configuration - disable Git integration, auto fetch behavior; Telemetry Configuration - disable telemetry ...
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