title: Creating and using an object after being inserted into DB [nodejs]
body: <p>I have a user class and a database class:</p>
  
  <p>User.js</p>
  
  <pre><code>const Database = require('./database')
  const myDB = new Database()
  
  function User (userID) {
    this.userID = userID
    myDB.insertUser(userID)
  }
  </code></pre>
  
  <p>Database.js</p>
  
  <pre><code>function Database () {
    const db = new sqlite3.Database(dbName)
    db.serialize(() =&gt; {
      db.run(`CREATE TABLE IF NOT EXISTS ${userTable} (user_id TEXT, balance INT)`)
    })
    db.close()
  }
  
  Database.prototype.insertUser = function (userID, cb) {
  // code
  }
  
  Database.prototype.getName = function (userID, cb) {
  // code
  }
  </code></pre>
  
  <p>I want to do the following, but am unsure as to how to do it synchronously:</p>
  
  <pre><code>const john = new User('john')
  console.log(john.getName())
  </code></pre>
  
  <p>What are the best practices on creating objects that are added to the DB but then used straightaway?</p>