Skip to content

Commit

Permalink
Expose the mongodb driver database instance from the Database object
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegn committed Aug 23, 2012
1 parent 3940d5b commit 407053f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/poutine/database.coffee
Expand Up @@ -15,12 +15,12 @@ catch ex
# driver, specifically it's Db object. # driver, specifically it's Db object.
class Configuration class Configuration
constructor: (name, options = {})-> constructor: (name, options = {})->
server = new Server(options.host || "127.0.0.1", options.port || 27017)
@_client = new Db(name, server, options)
@_pool = new Pool @_pool = new Pool
name: name name: name
create: (callback)=> create: (callback)=>
server = new Server(options.host || "127.0.0.1", options.port || 27017) @_client.open callback
client = new Db(name, server, options)
client.open callback
destroy: (connection)-> destroy: (connection)->
connection.close() connection.close()
max: options.pool || 50 max: options.pool || 50
Expand All @@ -43,6 +43,7 @@ class Configuration
class Database extends EventEmitter class Database extends EventEmitter
constructor: (@_configuration)-> constructor: (@_configuration)->
@_collections = [] @_collections = []
@db = @_configuration._client
@ObjectID = require("mongodb").BSONPure.ObjectID @ObjectID = require("mongodb").BSONPure.ObjectID
# Tracks how many times we called begin, only release TCP connection # Tracks how many times we called begin, only release TCP connection
# when zero. # when zero.
Expand All @@ -51,6 +52,7 @@ class Database extends EventEmitter
weak this, -> weak this, ->
if @_connecting if @_connecting
@_configuration.release @_connection @_configuration.release @_connection
return this


# Use this if you need access to the MongoDB driver's connection object. It # Use this if you need access to the MongoDB driver's connection object. It
# passes, error, a connection and a reference to the end method. Don't forget # passes, error, a connection and a reference to the end method. Don't forget
Expand Down

0 comments on commit 407053f

Please sign in to comment.