title: How to work with async and await with select from database in node js
body: <p>I have done one project where I used one callback so far, but with a bigger code base I already have chaos in it. I would like to move on to something new, specifically on async functions.</p>
  
  <p>I'm using an oop pattern, so I'd like this to be implemented right into the oop.
  The problem is that, I've never done this before and I don't know how to do it. I have some basic code with a callback. Could anyone change this to an async function, please?</p>
  
  <p><b>server.js</b></p>
  
  <pre><code>const object = require("./object");
  
  new object(userID).name((data) =&gt; {
    console.log(data);
  });
  </code></pre>
  
  <p><b>object.js</b></p>
  
  <pre><code>module.exports = class{
  
    constructor(userID){
      this.id = userID;
    }
  
    name(callback){
      mysqli.query("SELECT meno FROM uzivatelia WHERE id='"+ this.id +"'", (err, user) =&gt; {
        callback(user[0].meno);
      });
    }
  
  }
  </code></pre>