Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | 3x 3x 3x 3x 3x 3x | 'use strict'
const mongoose = require('mongoose')
const config = require('../config/env')
// const paginate = require('../libs/plugins/paginate')
mongoose.Promise = global.Promise
mongoose
.connect(config.mongo.uri, config.mongo.options)
.then(
() => { console.log('------ Mongodb connection succeed ------') },
err => { console.log('------ Mongodb connection failed ------' + err) }
);
// 放在全局部分,可能会影响性能
// mongoose.plugin(paginate)
module.exports = mongoose
// mongoose.connection.once('connected', function() {}
// mongoose.connection.on('error',function(){}
// mongoose.connection.on('error', handleError);
// class Mongo {
// constructor(app, config) {
// Object.assign(this, {
// app,
// config,
// })
// this.init()
// }
// init() {
// this.dblink = config.config.db;
// const opts = {
// server: {
// socketOptions: {
// socketTimeoutMS: 0,
// keepAlive: true
// },
// reconnectTries: 3
// },
// }
// mongoose
// // .connect(this.dblink, opts)
// .connect(config.mongo.uri, config.mongo.options)
// .then(
// () => { console.log('------ Mongodb connection succeed ------') },
// err => { console.log('------ Mongodb connection failed ------' + err) }
// );
// mongoose.Promise = global.Promise;
// }
// }
// module.exports = Mongo |