Files
talk/src/core/server/services/mongodb/index.ts
T
Wyatt Johnson 6f80a2458c linting
2018-06-21 10:44:36 -06:00

17 lines
545 B
TypeScript

import { MongoClient, Db } from "mongodb";
import { Config } from "talk-server/config";
/**
* create will connect to the MongoDB instance identified in the configuration.
*
* @param config application configuration.
*/
export async function createMongoDB(config: Config): Promise<Db> {
// Connect and create a client for MongoDB.
const client = await MongoClient.connect(config.get("mongodb"));
// Return the database handle, which defaults to the database name provided
// in the config connection string.
return client.db();
}