const { MongoClient } = require('mongodb');

/**
 * @returns {Promise<MongoClient>}
 */
export function connectToMongo() {
  return new Promise(async (resolve, reject) => {
    MongoClient.connect(
      'mongodb+srv://admin:milo@cluster0-6pqfq.mongodb.net/test?retryWrites=true',
      (error, client) => {
        if (error) {
          console.error(error);
          reject(error);
        } else {
          resolve(client);
        }
      },
    );
  });
}

export function closeConnection() {
  return null;
}
