reactivemongo.api

MongoConnection

class MongoConnection extends AnyRef

A pool of MongoDB connections, obtained from a reactivemongo.api.MongoDriver.

Connection here does not mean that there is one open channel to the server: behind the scene, many connections (channels) are open on all the available servers in the replica set.

Example:

import scala.concurrent.ExecutionContext
import reactivemongo.api._

def foo(driver: AsyncDriver)(implicit ec: ExecutionContext) = {
  val con = driver.connect(List("localhost"))
  val db = con.flatMap(_.database("plugin"))
  val collection = db.map(_("acoll"))
}
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. MongoConnection
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by any2stringfmt
  3. by any2ArrowAssoc
  4. by any2Ensuring
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new MongoConnection(supervisor: String, name: String, actorSystem: ActorSystem, mongosystem: ActorRef, options: MongoConnectionOptions)

    supervisor

    the name of the supervisor

    name

    the unique name for the connection pool

    mongosystem

    the reference to the internal reactivemongo.core.actors.MongoDBSystem Actor.

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def +(other: String): String

    Implicit information
    This member is added by an implicit conversion from MongoConnection to StringAdd performed by method any2stringadd in scala.Predef.
    Definition Classes
    StringAdd
  5. def ->[B](y: B): (MongoConnection, B)

    Implicit information
    This member is added by an implicit conversion from MongoConnection to ArrowAssoc[MongoConnection] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  6. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  8. def active: Boolean

    Returns true if the connection has not been killed.

    Returns true if the connection has not been killed.

    Annotations
    @inline()
  9. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  10. def authenticate(db: String, user: String, password: String, failoverStrategy: FailoverStrategy = options.failoverStrategy)(implicit ec: ExecutionContext): Future[SuccessfulAuthentication]

    Authenticates the connection on the given database.

    Authenticates the connection on the given database.

    db

    the database name

    user

    the user name

    password

    the user password

    failoverStrategy

    the failover strategy for sending requests

    import scala.concurrent.{ ExecutionContext, Future }
    import reactivemongo.api.MongoConnection
    
    def authDB(con: MongoConnection, user: String, pass: String)(
      implicit ec: ExecutionContext): Future[Unit] =
      con.authenticate("myDB", user, pass).map(_ => {})
      // with configured failover
    See also

    DB.authenticate

    MongoConnectionOptions.credentials

  11. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  12. def close()(implicit timeout: FiniteDuration): Future[_]

    Closes this connection (closes all the channels and ends the actors).

    Closes this connection (closes all the channels and ends the actors).

    import scala.concurrent.{ ExecutionContext, Future }
    import scala.concurrent.duration._
    
    import reactivemongo.api.MongoConnection
    
    def afterClose(con: MongoConnection)(
      implicit ec: ExecutionContext): Future[Unit] =
      con.close()(5.seconds).map { res =>
        println("Close result: " + res)
      }
  13. def database(name: String, failoverStrategy: FailoverStrategy = options.failoverStrategy)(implicit ec: ExecutionContext): Future[DefaultDB]

    Returns a DefaultDB reference using this connection.

    Returns a DefaultDB reference using this connection. The failover strategy is also used to wait for the node set to be ready, before returning an valid database reference.

    name

    the database name

    failoverStrategy

    the failover strategy for sending requests

    import scala.concurrent.{ ExecutionContext, Future }
    import reactivemongo.api.{ DefaultDB, MongoConnection }
    
    def resolveDB(con: MongoConnection, name: String)(
      implicit ec: ExecutionContext): Future[DefaultDB] =
      con.database(name) // with configured failover
  14. def ensuring(cond: (MongoConnection) ⇒ Boolean, msg: ⇒ Any): MongoConnection

    Implicit information
    This member is added by an implicit conversion from MongoConnection to Ensuring[MongoConnection] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. def ensuring(cond: (MongoConnection) ⇒ Boolean): MongoConnection

    Implicit information
    This member is added by an implicit conversion from MongoConnection to Ensuring[MongoConnection] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  16. def ensuring(cond: Boolean, msg: ⇒ Any): MongoConnection

    Implicit information
    This member is added by an implicit conversion from MongoConnection to Ensuring[MongoConnection] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  17. def ensuring(cond: Boolean): MongoConnection

    Implicit information
    This member is added by an implicit conversion from MongoConnection to Ensuring[MongoConnection] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  18. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  19. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  20. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  21. def formatted(fmtstr: String): String

    Implicit information
    This member is added by an implicit conversion from MongoConnection to StringFormat performed by method any2stringfmt in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  22. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  23. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  24. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  25. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  26. final def notify(): Unit

    Definition Classes
    AnyRef
  27. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  28. val options: MongoConnectionOptions

  29. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  30. def toString(): String

    Definition Classes
    MongoConnection → AnyRef → Any
  31. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. def [B](y: B): (MongoConnection, B)

    Implicit information
    This member is added by an implicit conversion from MongoConnection to ArrowAssoc[MongoConnection] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Shadowed Implicit Value Members

  1. val self: Any

    Implicit information
    This member is added by an implicit conversion from MongoConnection to StringAdd performed by method any2stringadd in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (mongoConnection: StringAdd).self
    Definition Classes
    StringAdd
  2. val self: Any

    Implicit information
    This member is added by an implicit conversion from MongoConnection to StringFormat performed by method any2stringfmt in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (mongoConnection: StringFormat).self
    Definition Classes
    StringFormat

Deprecated Value Members

  1. val actorSystem: ActorSystem

    Annotations
    @deprecated
    Deprecated

    (Since version 0.14.0) Internal: will be made private

  2. def askClose()(implicit timeout: FiniteDuration): Future[_]

    Annotations
    @deprecated
    Deprecated

    (Since version 0.19.4) Use close

  3. def authenticate(db: String, user: String, password: String): Future[SuccessfulAuthentication]

    Annotations
    @deprecated
    Deprecated

    (Since version 0.14.0) Use authenticate with failoverStrategy

  4. val mongosystem: ActorRef

    the reference to the internal reactivemongo.core.actors.MongoDBSystem Actor.

    the reference to the internal reactivemongo.core.actors.MongoDBSystem Actor.

    Annotations
    @deprecated
    Deprecated

    (Since version 0.17.0) Internal: will be made private

  5. val name: String

    the unique name for the connection pool

    the unique name for the connection pool

    Annotations
    @deprecated
    Deprecated

    (Since version 0.17.0) Internal: will be made private

  6. val supervisor: String

    the name of the supervisor

    the name of the supervisor

    Annotations
    @deprecated
    Deprecated

    (Since version 0.17.0) Internal: will be made private

  7. def x: MongoConnection

    Implicit information
    This member is added by an implicit conversion from MongoConnection to ArrowAssoc[MongoConnection] performed by method any2ArrowAssoc in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (mongoConnection: ArrowAssoc[MongoConnection]).x
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use leftOfArrow instead

  8. def x: MongoConnection

    Implicit information
    This member is added by an implicit conversion from MongoConnection to Ensuring[MongoConnection] performed by method any2Ensuring in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (mongoConnection: Ensuring[MongoConnection]).x
    Definition Classes
    Ensuring
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use resultOfEnsuring instead

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from MongoConnection to StringAdd

Inherited by implicit conversion any2stringfmt from MongoConnection to StringFormat

Inherited by implicit conversion any2ArrowAssoc from MongoConnection to ArrowAssoc[MongoConnection]

Inherited by implicit conversion any2Ensuring from MongoConnection to Ensuring[MongoConnection]

Ungrouped