<commit_before>const Settings = require('settings-sharelatex')
const { MongoClient, ObjectId } = require('mongodb')

const clientPromise = MongoClient.connect(Settings.mongo.url)
const dbPromise = clientPromise.then((client) => client.db())

async function getCollection(name) {
  return (await dbPromise).collection(name)
}

async function waitForDb() {
  await clientPromise
}

module.exports = {
  ObjectId,
  getCollection,
  waitForDb
}<commit_msg>[misc] mongodb: drop intermediate dbPromise<commit_after>const Settings = require('settings-sharelatex')
const { MongoClient, ObjectId } = require('mongodb')

const clientPromise = MongoClient.connect(Settings.mongo.url)

async function getCollection(name) {
  return (await clientPromise).db().collection(name)
}

async function waitForDb() {
  await clientPromise
}

module.exports = {
  ObjectId,
  getCollection,
  waitForDb
}
{'fraction_non_alphanumeric': 0.1143827859569649, 'fraction_numerical': 0.0, 'mean_word_length': 6.015873015873016, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '340255', 'n_tokens_mistral': 269, 'n_tokens_neox': 262, 'n_words': 58}