Boilerplate generator and deno tasks for monorepo
This commit is contained in:
16
lib/data.ts
Normal file
16
lib/data.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
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 })!)
|
||||
}
|
Reference in New Issue
Block a user