Skip to content

Documenting the use of through in find with BelongsToMany association #3416

Closed

Description

@yonjah

The only mention of this I could find was in -
#3258

I would suggest adding -

When eager loading the through parameter can be used to define the required relations.
The following example will only fetch Projects that have been started -

User.findAll({ 
    include: [{
        model: Project,
        through: {
            where: {started: true}
        }
    }]
}).then(...);

To http://docs.sequelizejs.com/en/latest/api/associations/#belongstomanytarget-options

This would probably be enough to hint most users about the use of through but you might want to document its full API

Activity

  1. added
    docs
    on Mar 27, 2015
  2. mickhansen commented on Mar 27, 2015

    @mickhansen
    Contributor

    Both through.where and through.attributes need to be documented definitely.

  3. harimohanraj89 commented on Apr 8, 2015

    @harimohanraj89
    Contributor

    @mickhansen The documentation for through.where and through.attributes applies to all associations between models, yes (hasOne, hasMany, belongsTo, belongsToMany)? Would it make sense to add this to all four documentation sections?

  4. mickhansen commented on Apr 9, 2015

    @mickhansen
    Contributor

    @harimohanraj89 No, through only exists on belongsToMany.

  5. harimohanraj89 commented on Apr 9, 2015

    @harimohanraj89
    Contributor

    Ah, my mistake. I was thinking of the include option on finder methods. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions