sequelize / sequelize/sequelize

Query table with 3 associations

Open
#11,849 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
TypeScript
Stars
30.4k
Forks
4.3k
Avg merge
1d 6h
Merged PRs (30d)
68

Description

Issue Description

What was unclear/insufficient/not covered in the documentation

The docs covered several M:N scenarios, but could not find how to do my specific use case.

An M:N table that links to an M:N table, applying a filter on all 3. For example:

A user has many projects, which has many tasks. When retrieving a user and doing an eager load on both project and tasks, I would expect the query to apply the ON query correctly (i.e. ON task_id = task.id AND project_id = project.id AND user_id = user.id)

If possible: Provide some suggestion on how we can enhance the docs

I feel this is a common scenario and having a similar example could prove useful (apologies if there is one somewhere and I missed it). A section on having multi-associations somewhere.

Additional context

I have created a repl.it here to demonstrate my problem.

Issue Template Checklist

Is this issue dialect-specific?
  • No. This issue is relevant to Sequelize as a whole.
  • Yes. This issue only applies to the following dialect(s): XXX, YYY, ZZZ
  • I don't know.
Would you be willing to resolve this issue by submitting a Pull Request?
  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I don't know how to start, I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked repl.it reproduction and the issue's description of nested many-to-many eager loading. Determine the expected behavior and document a comparable three-association example, including how the filters should be applied; done means the scenario and its limitations are clear in the Sequelize documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
backend, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.