import mongoose from 'mongoose'; import { vault } from 'common/vault.ts'; /** * * @param dbName The Database to open */ export const configDatabase = async (mg: typeof mongoose, dbName = 'BattleLog') => { if (!vault.get('MONGODB_URI')) throw 'No MongoDB URI, is your secrets file present and populated?' await mg.connect(vault.getf('MONGODB_URI', { db: dbName })!) } export const openDatabase = async (mg: typeof mongoose, dbName = 'BattleLog') => { if (!vault.get('MONGODB_URI')) throw 'No MongoDB URI, is your secrets file present and populated?' return await mg.connect(vault.getf('MONGODB_URI', { db: dbName })!) }