title: sequelize ORM asynchronous method calls
body: <p>How can I call methods asynchronously in sequelize ORM? (because I have to use returned value inside other methods). </p>
  
  <p>user.dao.js: </p>
  
  <pre><code>var User = require('./user.model');
  
  class UserDao {
  constructor() {}
  
  insert(user) {
      var pk;
      User.sync({ force: false }).then(() =&gt; {
          User.create(user).then(function(user) {
              console.log('Entry successful from dao: ' + 
      JSON.stringify(user));
              //return generated pk
              pk = user.id;
              console.log('ID: ' + pk);
          });
      });
      return pk;
  }
  </code></pre>
  
  <p>user.test.js:</p>
  
  <pre><code>class UserDaoTest {
  constructor() {
      this.userDao = new UserDao();
      this.compare = new UtilsObject();
  }
  
  /*
      all CRUD method calls
  */
  testAll() {
      this.testInsert();
      this.testUpdate();
      //this.testDelete();
      //this.testRead();
      //this.compare();
  }
  
  /*
      insert method
  */
  testInsert() {
      // composite form
      var user = {
          name: 'nisha',
          email: 'nisha@gmail.com',
          phoneNo: 8978,
          picUrl: 'nisha',
          description: 'SI',
          status: 'active',
          waitingTime: 10,
          rating: 7
      };
  
      /*
          calling insert user with above data
      */
      var pk = this.userDao.insert(user);
      console.log('pk value: ' + pk);
      //var obj1 = this.userDao.readById(pk);
      console.log('obj1 value: ' + user);
      //this.testReadById(obj1);
  }
  
  testReadById(obj1) {
      var obj2 = this.userDao.readById(obj1);
      this.compare.compare(obj1, obj2);
      this.testDelete(obj1);
  }
  }
  
  export default UserDaoTest;
  </code></pre>
  
  <p>Here in user.test.js, in testInsert() method want to get the value of pk which is returned from insert() method of user.dao.js, but right now I am getting pk value as undefined. </p>