I'm having following code.
class DB {
constructor(client) {
this.client = client;
}
}
export default function store() {
return new Promise((resolve, reject) => {
pg.connect(process.env.DATABASE_URL, client => {
client.query('CREATE TABLE x(name VARCHAR(100))');
return resolve(new DB(client));
});
});
}
Is there any way to move store function inside the class constructor and rewrite it using async/await?