Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for version 3.6 of mongodb library. #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions scripts/hubot-mongodb-brain.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

_ = require 'lodash'
MongoClient = require('mongodb').MongoClient
Url = require('url')

deepClone = (obj) -> JSON.parse JSON.stringify obj

Expand All @@ -25,11 +26,16 @@ module.exports = (robot) ->
process.env.MONGOHQ_URL or
'mongodb://localhost/hubot-brain'

MongoClient.connect mongoUrl, (err, db) ->
MongoClient.connect mongoUrl, (err, client) ->
throw err if err

robot.brain.on 'close', ->
db.close()
client.close()

urlInfo = Url.parse(mongoUrl)

db = client.db(if urlInfo.pathname then urlInfo.pathname.replace('/','') \
else 'hubot-brain')

robot.logger.info "MongoDB connected"
robot.brain.setAutoSave false
Expand Down