title: bind value of callack to property of instance nodejs
body: <p>I want to permanently store a result of a callback function, here is the code:</p>
  
  <pre><code>class constants {
      constructor(){
         this.acquire()
      }
  
      acquire() {
         this.last_refresh = new Date().getDate();
          require('./db_slave').then(conn =&gt; {
              return conn.query("SELECT table_name FROM information_schema.tables where table_schema='gen'").then(result =&gt; {
                  this.tables = result
                  console.log(result)
              });
          }).catch(err =&gt; {
              // handle error here
          });
      }
  
      tables() {
          this.refresh()
          return this.tables
      }
      refresh() { if (new Date().getDate() != this.last_refresh) this.acquire() }
  }
  
  module.exports = constants
  </code></pre>
  
  <p>but this is obviously not working because <code>this.tables = result</code> doesnt do anything...</p>
  
  <p>Here is the file that is being called by this promise:</p>
  
  <pre><code>var mysql = require('promise-mysql');
  var db = require('./db')
  
  module.exports = mysql.createConnection({
      host: db.host,
      user: db.user,
      password: db.password
  }).then(conn =&gt; {
      console.log("connected to the DB");
      return conn;
  }).catch(err =&gt; {
      console.log("error connecting to the DB", err);
      throw err;
  });
  </code></pre>
  
  <p>How do i permanently store the result in that callback?</p>
  
  <p>here is how i used these:</p>
  
  <pre><code>var db_constants = require('./database_service/db_constants')
  
  let cons = new db_constants()
  
  console.log(cons.tables())
  </code></pre>