Skip to content

Commit

Permalink
remove undeclared require('mongodb') call
Browse files Browse the repository at this point in the history
  • Loading branch information
mizzao committed Mar 17, 2015
1 parent 9291e9b commit 05b625e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/server/db/mongo.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
# This implementation isn't written to support multiple frontends
# talking to a single mongo backend.

mongodb = require 'mongodb'

defaultOptions =
# Prefix for all database keys.
db: 'sharejs'
Expand All @@ -30,7 +28,11 @@ module.exports = MongoDb = (options) ->
options ?= {}
options[k] ?= v for k, v of defaultOptions

client = options.client or new mongodb.Db(options.db, new mongodb.Server(options.hostname, options.port, options.mongoOptions), {safe: true})
if options.client?
client = options.client
else
mongodb = require 'mongodb'
client = new mongodb.Db(options.db, new mongodb.Server(options.hostname, options.port, options.mongoOptions), {safe: true})

client.open (err, db) ->
if not err
Expand Down

0 comments on commit 05b625e

Please sign in to comment.