title: Get only values from rows and associations with Sequelize
body: <p>I am using Sequelize, MySQL and Node to write a web application.</p>
  
  <p>For most of my DB needs, I usually do some verification, then fetch my models (eagerly with associations) and send them back to the client, almost always as-is (at least, up to now).</p>
  
  <p>I wrote a little utility function <code>getValuesFromRows</code> to extract the values from a returned row array:</p>
  
  <pre><code>getValuesFromRows: function(rows, valuesProp) {
      // get POD (plain old data) values
      valuesProp = valuesProp || 'values';
      if (rows instanceof Array) {
          var allValues = [];
          for (var i = 0; i &lt; rows.length; ++i) {
              allValues[i] = rows[i][valuesProp];
          }
          return allValues;
      }
      else if (rows) {
          // only one object
          return rows[valuesProp];
      }
      return null;
  }
  
  // ...
  
  ...findAll(...)...complete(function(err, rows) {
       var allValues = getValuesFromRows(rows);
       sendToClient(errToString(err, user), allValues);
  });
  </code></pre>
  
  <p>However, I am adding more and more complex relations to my DB models. As a result, I get more associations that I have to fetch. Now, I don't only have to call above function to get the <code>values</code> from each row, but also I need more complicated utilities to get the <code>values</code> from all included (eagerly loaded) associations. Is there a way to only get values from Sequelize queries (and not the Sequelize model instance) that also includes all associated values from the instance?</p>
  
  <p>Else, I would have to manually "get all <code>values</code> from each <code>Project</code> and add one item to that <code>values</code> object for the <code>values</code> property of each entry of <code>Project.members</code>" (for example). Note that things get worse fast if you nest associations (e.g. members have <code>tasks</code> and <code>tasks</code> have this and that etc.).</p>
  
  <p>I am guessing that I have to write such utility myself?</p>