title: Return flat object from sequelize with association
body: <p>I am working on converting all my queries in sequelize. 
  The problem I have come across is that when select queries include associations (ex. one to many), the object I get is an array of nested objects.</p>
  
  <p>It looks something like:</p>
  
  <pre><code>[   
    {
      "field1": "someval",
      "field2": "someval1",
      "assoc_table": {
        "field_a": 1,
        "field_b": "someval"
      }   
    },   
    {
      "field1": "someval",
      "field2": "someval3",
      "assoc_table": {
        "field_a": 5,
        "field_b": "someval"
      }   
    },   
    {
      "field1": "someval",
      "field2": "someval3",
      "assoc_table": {
        "field_a": 12,
        "field_b": "someval"
      }   
     } 
  ]
  </code></pre>
  
  <p>I tried to use different modules to flatten the objects (inside a loop, each object individually), but I always got an error telling that what I was trying to flatten were not just objects.</p>
  
  <p>Moreover, I would prefer avoiding the part where objects are flattened, and simply get a flat result with sequelize.</p>
  
  <p>The sequelize code looks something like this:</p>
  
  <pre><code>models.table1.findAll({
      attributes: ['field1', 'field2'],
      where: {field1: someval},
      include: [{model: models.assoc_table, required: true, attributes:['field_a', 'field_b']}]
  }).then(function (result) {
      res.send(result);
  }).catch(function(error) {
      console.log(error);
  });
  </code></pre>