Hello airbnb

This commit is contained in:
masnn committed 2020-04-15 15:08:05 +08:00
1 parent f9468536de
commit 8c195661d7
78 files changed
+2032 -1471

No files matched your search

+4 -3
View File
@@ -1,19 +1,20 @@
const Mongo = require('mongodb');
const options = require('../options');
let mongourl = 'mongodb://';
if (options.db.username) mongourl += options.db.username + ':' + options.db.password + '@';
if (options.db.username) mongourl += `${options.db.username}:${options.db.password}@`;
mongourl += `${options.db.host}:${options.db.port}/${options.db.name}`;
/**
* @type {import('mongodb').Db}
*/
let db = null;
Mongo.MongoClient.connect(mongourl, { useNewUrlParser: true, useUnifiedTopology: true })
.then(Database => {
.then((Database) => {
db = Database.db(options.db.name);
db.Db = Database;
global.bus.emit('connected');
});
module.exports = {
collection: c => db.collection(c)
collection: (c) => db.collection(c),
};