2015-05-07 10:08:11 -04:00
|
|
|
mongoose = require('mongoose')
|
|
|
|
Settings = require 'settings-sharelatex'
|
|
|
|
logger = require('logger-sharelatex')
|
|
|
|
|
2017-11-22 08:37:57 -05:00
|
|
|
mongoose.connect(Settings.mongo.url, {
|
|
|
|
server: {poolSize: 10},
|
|
|
|
config: {autoIndex: false}
|
|
|
|
})
|
2015-05-07 10:08:11 -04:00
|
|
|
|
|
|
|
mongoose.connection.on 'connected', () ->
|
|
|
|
logger.log {url:Settings.mongo.url}, 'mongoose default connection open'
|
|
|
|
|
|
|
|
mongoose.connection.on 'error', (err) ->
|
|
|
|
logger.err err:err, 'mongoose error on default connection';
|
|
|
|
|
|
|
|
mongoose.connection.on 'disconnected', () ->
|
|
|
|
logger.log 'mongoose default connection disconnected'
|
|
|
|
|
2019-05-28 05:15:37 -04:00
|
|
|
if process.env.MONGOOSE_DEBUG
|
|
|
|
mongoose.set 'debug', (collectionName, method, query, doc) ->
|
|
|
|
logger.debug 'mongoose debug', collectionName: collectionName, method: method, query: query, doc: doc
|
|
|
|
|
2015-05-07 10:08:11 -04:00
|
|
|
module.exports = mongoose
|