Skip to content

Documentation for hasMany and belongsTo is unclear #10860

Closed

Description

@tsjohns9

What was unclear/insufficient/not covered in the documentation

In the documentation the Associations tab has a section labeled Difference between HasOne and BelongsTo, and it is clear about the the difference between the two when it states

HasOne and BelongsTo insert the association key in different models from each other. HasOne inserts the association key in target model whereas BelongsTo inserts the association key in the source model.

That explanation makes sense, but the example makes it really unclear as to what is going on when we are presented with this example:

Project.belongsToMany(User, {through: 'UserProject'});
User.belongsToMany(Project, {through: 'UserProject'});

If the two do the same thing, but insert the keys to the other table in different ways, then why would we want to define this relationship twice? It is confusing, and a reader cannot get a sufficient understanding about why we are given this example, and it is used repeatedly throughout the documentation.

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

Since the documentation is unclear the reader needs to then go to stack overflow to find the answer, and hopefully they find this question, and then read the second provided answer, which explains it perfectly.

Thank you

Activity

  1. added
    docs
    on Apr 29, 2019
  2. self-assigned this
    on Jul 18, 2019
  3. added
    status: understood
    on Jul 26, 2019
  4. added
    status: wip
    and removed
    status: understood
    on Sep 6, 2019
  5. removed
    status: wip
    on Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

docs

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions