Sharkey/src/db/mongodb.ts

9 lines
412 B
TypeScript
Raw Normal View History

2016-12-29 00:49:51 +02:00
import * as mongodb from 'mongodb';
export default async function(): Promise<mongodb.Db> {
const uri = config.mongodb.user && config.mongodb.pass
? `mongodb://${config.mongodb.user}:${config.mongodb.pass}@${config.mongodb.host}:${config.mongodb.port}/${config.mongodb.db}`
: `mongodb://${config.mongodb.host}:${config.mongodb.port}/${config.mongodb.db}`;
return await mongodb.MongoClient.connect(uri);
};