mongojs.js 825 B

123456789101112131415161718192021222324252627
  1. // TODO: This file was created by bulk-decaffeinate.
  2. // Sanity-check the conversion and remove this comment.
  3. /*
  4. * decaffeinate suggestions:
  5. * DS102: Remove unnecessary code created because of implicit returns
  6. * DS207: Consider shorter variations of null checks
  7. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  8. */
  9. const Settings = require('settings-sharelatex')
  10. const mongojs = require('mongojs')
  11. const db = mongojs(Settings.mongo.url, ['docSnapshots'])
  12. module.exports = {
  13. db,
  14. ObjectId: mongojs.ObjectId,
  15. healthCheck(callback) {
  16. return db.runCommand({ ping: 1 }, function (err, res) {
  17. if (err != null) {
  18. return callback(err)
  19. }
  20. if (!res.ok) {
  21. return callback(new Error('failed mongo ping'))
  22. }
  23. return callback()
  24. })
  25. }
  26. }