title: Executing Multiple Sequelize JS model query methods with Promises - Node
body: <p>I am having a problem retrieving data from database using sequelize js. I am new to NODEJS. I don't know if Promise and Promise.all are built in functions 
  So i install and require npm promise in my code too.
  Below is my code.</p>
  
  <pre><code>var Promise = require('promise');
  
  var user_profile = new Promise(function(resolve, reject) {
      db.user_profile.findOne({
          where: {
              profile_id: new_profile_id
          }
      }).then(user =&gt; {
          console.log('Summary Result User found.');
          resolve(user);
      });
  });
  
  var all_reports = new Promise(function(resolve, reject) {
      db.report.all().then(reports =&gt; {
          console.log('Summary Result Reports found.');
          resolve(reports);
      });
  });
  
  var report_details = new Promise(function(resolve, reject) {
      db.report_detail.findAll({
          where: {
              profile_id: new_profile_id
          }
      }).then(report_details =&gt; {
          console.log('Summary Result Report Details found');
          resolve(report_details);
      });
  });
  
  var all_promises = Promise.all([user_profile, all_reports, report_details]).then(function(data) {
      console.log('**********COMPLETE RESULT****************');
      console.log(data);
  }).catch(err =&gt; {
      console.log('**********ERROR RESULT****************');
      console.log(err);
  });
  </code></pre>
  
  <p>I want to get the data of all three queries. When i run them individually I get the data but when i run them in Promise.all I only get user_profile data and other two remain <strong>undefined</strong>
  I have also tried nested these queries with .then but result is still same I only get one query data other two remain <strong>undefined</strong></p>
  
  <p><strong>with then chainging</strong></p>
  
  <pre><code>var results = [];
  var new_profile_id = req.params.profile_id;
  console.log(new_profile_id);
  db.user_profile.findOne({
      where: {
          profile_id: new_profile_id
      }
  }).then(user =&gt; {
      console.log('Summary Result User found.');
      results.push(user.dataValues);
      return user;
  }).then(user =&gt; {
      db.report.all().then(reports =&gt; {
          console.log('Summary Result Reports found.');
          results.push(reports.dataValues);
          return reports
      });
  }).then(reports =&gt; {
      db.report_detail.findAll({
          where: {
              profile_id: new_profile_id
          }
      }).then(report_details =&gt; {
          console.log('Summary Result Report Details found');
          results.push(report_details.dataValues);
          console.log('**********COMPLETE RESULT****************');
          console.log(results);
          console.log('**********COMPLETE RESULT****************');
          return report_details;
      });
  });
  </code></pre>
  
  <p>can someone please help me in this concept what i am doing wrong.
  Thanks</p>