title: How to use both 'include' and 'attributes' in 'findByPk' statement in Sequelize?
body: <p>How to use both 'include' and 'attributes' in 'findByPk' statement in Sequelize. This is my code:</p>
  <pre><code>exports.findOne = (req, res) =&gt; {
    var id = req.params.id;
  
    User.findByPk(id, 
      
      {
        include: [&quot;roles&quot;] 
      }, 
      {
        attributes: {
           exclude: ['password']
        }
      }
      )
        .then(data =&gt; {
          res.send({&quot;data&quot;: data, &quot;resultCode&quot;: 1, &quot;message&quot;: &quot;&quot;});
        })
        .catch(err =&gt; {
          res.status(500).send({
            message:
              err.message || &quot;Some error occurred while retrieving users.&quot;
          });
        });;
  
  }
  </code></pre>
  <p>But it only works when I use 1 of 2 only.
  If I just use: <code>attributes: { exclude: ['password']}</code> the result is as follows:</p>
  <pre><code>{
      &quot;data&quot;: {
          &quot;id&quot;: 1,
          &quot;username&quot;: &quot;admin&quot;,
          &quot;email&quot;: &quot;admin@gmail.com&quot;,
          &quot;createdAt&quot;: &quot;2021-09-27T04:22:56.660Z&quot;,
          &quot;updatedAt&quot;: &quot;2021-09-27T04:22:56.660Z&quot;
      },
      &quot;resultCode&quot;: 1,
      &quot;message&quot;: &quot;&quot;
  }
  </code></pre>
  <p>If I just use: <code>{include: [&quot;roles&quot;]}</code> so the result is as follows</p>
  <pre><code>{
      &quot;data&quot;: {
          &quot;id&quot;: 1,
          &quot;username&quot;: &quot;admin&quot;,
          &quot;email&quot;: &quot;admin@gmail.com&quot;,
          &quot;password&quot;: &quot;$2a$08$m54ioIwzpZRVC9/HqkHyqezOornjmvT9pDEJcOhHbNcSmLOfw3Sg.&quot;,
          &quot;createdAt&quot;: &quot;2021-09-27T04:22:56.660Z&quot;,
          &quot;updatedAt&quot;: &quot;2021-09-27T04:22:56.660Z&quot;,
          &quot;roles&quot;: [
              {
                  &quot;id&quot;: 2,
                  &quot;name&quot;: &quot;moderator&quot;,
                  &quot;createdAt&quot;: &quot;2021-09-27T04:20:46.956Z&quot;,
                  &quot;updatedAt&quot;: &quot;2021-09-27T04:20:46.956Z&quot;,
                  &quot;user_roles&quot;: {
                      &quot;createdAt&quot;: &quot;2021-09-27T04:22:56.791Z&quot;,
                      &quot;updatedAt&quot;: &quot;2021-09-27T04:22:56.791Z&quot;,
                      &quot;roleId&quot;: 2,
                      &quot;userId&quot;: 1
                  }
              },
              {
                  &quot;id&quot;: 3,
                  &quot;name&quot;: &quot;admin&quot;,
                  &quot;createdAt&quot;: &quot;2021-09-27T04:20:46.956Z&quot;,
                  &quot;updatedAt&quot;: &quot;2021-09-27T04:20:46.956Z&quot;,
                  &quot;user_roles&quot;: {
                      &quot;createdAt&quot;: &quot;2021-09-27T04:22:56.791Z&quot;,
                      &quot;updatedAt&quot;: &quot;2021-09-27T04:22:56.791Z&quot;,
                      &quot;roleId&quot;: 3,
                      &quot;userId&quot;: 1
                  }
              }
          ]
      },
      &quot;resultCode&quot;: 1,
      &quot;message&quot;: &quot;&quot;
  }
  
  </code></pre>
  <p>How to use both in my code? Because I dont want to show 'password' field in my result but I want to show the roles of user in my result. How to do like that. Thanks you in advanced</p>