mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
40316b0735
Allow very verbose debugging of mongo queries via env var GitOrigin-RevId: ad132ef0cc6df892b4c879948094f67497cc9a48
23 lines
751 B
CoffeeScript
23 lines
751 B
CoffeeScript
mongoose = require('mongoose')
|
|
Settings = require 'settings-sharelatex'
|
|
logger = require('logger-sharelatex')
|
|
|
|
mongoose.connect(Settings.mongo.url, {
|
|
server: {poolSize: 10},
|
|
config: {autoIndex: false}
|
|
})
|
|
|
|
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'
|
|
|
|
if process.env.MONGOOSE_DEBUG
|
|
mongoose.set 'debug', (collectionName, method, query, doc) ->
|
|
logger.debug 'mongoose debug', collectionName: collectionName, method: method, query: query, doc: doc
|
|
|
|
module.exports = mongoose
|