Skip to content

Instantly share code, notes, and snippets.

@KevinVR
Created July 22, 2021 19:02
Show Gist options
  • Select an option

  • Save KevinVR/fec419714870c75aa8d0cf6b786288c2 to your computer and use it in GitHub Desktop.

Select an option

Save KevinVR/fec419714870c75aa8d0cf6b786288c2 to your computer and use it in GitHub Desktop.
class DB {
private _connection: MongoClient;
private _db: Db;
constructor() {}
public async connect() {
const mongoClientPromise = MongoClient.connect(process.env.MONGODB_URI, { useNewUrlParser: true, useUnifiedTopology: true });
this._connection = await mongoClientPromise;
this._db = this._connection.db(process.env.MONGODB_NAME);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment