title: Sequelize returns join table in query
body: <p>I've got a many-to-many relation in my MSQL table between these two model:</p>
  
  <blockquote>
    <ul>
    <li>Venue - Representing a venue which can have multiple owners (employees)</li>
    <li>Employee - Representing an employee which can be either a ceo or sales employee or whatsoever.</li>
    </ul>
  </blockquote>
  
  <p><em>I am using <a href="/questions/tagged/sequelize" class="post-tag" title="show questions tagged &#39;sequelize&#39;" rel="tag">sequelize</a> to set up the relations like so:</em></p>
  
  <h3>Relation Employee > Venue</h3>
  
  <pre><code> Employee.associate = function (models) { 
     models.Employee.belongsToMany(models.Venue, { through: 'EmployeeVenues' })
   }
  </code></pre>
  
  <h3>Relation Venue > Employee</h3>
  
  <pre><code> Venue.associate = function (models) {
      models.Venue.belongsToMany(models.Employee, { through: 'EmployeeVenues' })
   }
  </code></pre>
  
  <h3>Sequelize docs</h3>
  
  <blockquote>
    <p>According to the <a href="http://docs.sequelizejs.com/manual/tutorial/associations.html" rel="noreferrer">Sequelize docs</a> it will create a new model called EmployeeVenues with the equivalent foreign keys employee_id and venue_id. Defining through is required. Sequelize would previously attempt to autogenerate names but that would not always lead to the most logical setups. This will add methods <strong>getVenues</strong>, setVenues, addVenue, addUsers to Employee.</p>
  </blockquote>
  
  <hr>
  
  <p>And this is correctly working, when I fire up my Sequelize it creates a new table called EmpoyeeVenues with the correct foreign keys as a compound key. However when I query getVenues it does not return the expected output. Instead, it's returning the associated table values as well, which I don't want. </p>
  
  <hr>
  
  <h3>Query to get all venues belonging to an employee with id equal 1</h3>
  
  <hr>
  
  <pre><code>router.get('/api/v1/users/:employee_id/venues', (request, response) =&gt; {
    var employeeId = request.params.employee_id;
  
    models.Employee.findOne({
      where: {id: employeeId}
    }).then((employee) =&gt; {
  
      if(!employee) { return response.status(400).send("Employee doesnt have a venue registered yet.")}
      var venues = employee.getVenues().then((venues) =&gt; {
      response.status(200).send(venues);
    })
  })
  });
  </code></pre>
  
  <h3>Response Result</h3>
  
  <hr>
  
  <pre><code>[
      {
          "id": 1,
          "capacity": "11",
          "venue_name": "Club Fix",
          "venue_description": "Club in Tilburg",
          "EmployeeVenues": {
              "employee_id": 1,
              "venue_id": 1
          }
      },
      {
          "id": 2,
          "capacity": "400",
          "venue_name": "Club Vie",
          "venue_description": "Club in Rotterdam",
          "EmployeeVenues": {
              "employee_id": 1,
              "venue_id": 2
          }
      }
  ]
  </code></pre>
  
  <h3>Question</h3>
  
  <blockquote>
    <p>Why is EmployeeVenues included in this query provided by Sequelize? And How can I prevent EmployeeVenues to be included in the response?</p>
  </blockquote>
  
  <p><br /></p>
  
  <h1>Update</h1>
  
  <blockquote>
    <p>According to a issue on the Sequelize github page which was made in 2014 there is a solution that works</p>
  </blockquote>
  
  <p><a href="https://github.com/sequelize/sequelize/issues/2143" rel="noreferrer">https://github.com/sequelize/sequelize/issues/2143</a></p>
  
  <pre><code>    User.find({
      where: {id: userId}, attributes: userFields,
      include: [
        {model: db.Role, attributes: roleFields, through: {attributes: []}}
      ]
  });
  </code></pre>
  
  <hr>
  
  <p>But it does not match the documented version in the Sequelize documentation which is up-to-date, at least it should be.</p>
  
  <hr>
  
  <pre><code>User.findAll({
    include: [{
      model: Project,
      through: {
        attributes: ['createdAt', 'startedAt', 'finishedAt'],
        where: {completed: true}
      }
    }]
  });
  </code></pre>
  
  <hr>
  
  <p>Or even simple stated on the <a href="http://docs.sequelizejs.com/class/lib/associations/base.js~Association.html" rel="noreferrer">reference documentation:</a></p>
  
  <hr>
  
  <pre><code>user.getPictures() // gets you all pictures
  </code></pre>