✌️
This commit is contained in:
parent
52af143a41
commit
87d14a9545
18 changed files with 59 additions and 34 deletions
|
@ -1,8 +1,11 @@
|
|||
import * as mongodb from 'mongodb';
|
||||
const mongo = require('mongoskin');
|
||||
|
||||
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);
|
||||
};
|
||||
import config from '../conf';
|
||||
|
||||
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}`;
|
||||
|
||||
const db = mongo.db(uri, { native_parser: true });
|
||||
|
||||
export default db;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue