2020-05-06 06:09:15 -04:00
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Sanity-check the conversion and remove this comment.
|
2020-05-06 06:08:21 -04:00
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* DS207: Consider shorter variations of null checks
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2020-05-06 06:09:33 -04:00
|
|
|
const Settings = require('settings-sharelatex')
|
|
|
|
const mongojs = require('mongojs')
|
|
|
|
const db = mongojs(Settings.mongo.url, ['docSnapshots'])
|
2019-08-07 11:25:23 -04:00
|
|
|
|
2020-05-06 06:08:21 -04:00
|
|
|
module.exports = {
|
2020-05-06 06:09:33 -04:00
|
|
|
db,
|
|
|
|
ObjectId: mongojs.ObjectId,
|
|
|
|
healthCheck(callback) {
|
|
|
|
return db.runCommand({ ping: 1 }, function (err, res) {
|
|
|
|
if (err != null) {
|
|
|
|
return callback(err)
|
|
|
|
}
|
|
|
|
if (!res.ok) {
|
|
|
|
return callback(new Error('failed mongo ping'))
|
|
|
|
}
|
|
|
|
return callback()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|