mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
module.add(user,problem,record)
This commit is contained in:
commit
d5b1f623f8
43 files changed
+5965
No files matched your search
@@ -0,0 +1,18 @@
|
||||
const Mongo = require('mongodb');
|
||||
const options = require('../options');
|
||||
let mongourl = 'mongodb://';
|
||||
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 => {
|
||||
db = Database.db(options.db.name);
|
||||
global.bus.emit('connected');
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
collection: c => db.collection(c)
|
||||
};
|
||||
Reference in new issue
Block a user