Class/Object

reactivemongo.api

MongoConnection

Related Docs: object MongoConnection | package api

Permalink

final class MongoConnection extends AnyRef

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

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 _ = db.map(_("acoll")) // Collection reference
}
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. MongoConnection
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  6. def active: Boolean

    Permalink

    Returns true if the connection has not been killed.

    Returns true if the connection has not been killed.

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

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

    Permalink

    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
    Annotations
    @SuppressWarnings()
    See also

    DB.authenticate

    MongoConnectionOptions.credentials

  9. def clone(): AnyRef

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

    Permalink

    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)
      }
  11. def database(name: String, failoverStrategy: FailoverStrategy = options.failoverStrategy)(implicit ec: ExecutionContext): Future[DB]

    Permalink

    Returns a DB reference using this connection.

    Returns a DB 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.{ DB, MongoConnection }
    def resolveDB(con: MongoConnection, name: String)(
      implicit ec: ExecutionContext): Future[DB] =
      con.database(name) // with configured failover
    Annotations
    @SuppressWarnings()
  12. def ensuring(cond: (MongoConnection) ⇒ Boolean, msg: ⇒ Any): MongoConnection

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

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

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

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

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

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

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

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

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

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

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

    Permalink
    Definition Classes
    AnyRef
  24. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  25. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  26. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  27. def toString(): String

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

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

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

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

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

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from MongoConnection to any2stringadd[MongoConnection]

Inherited by implicit conversion StringFormat from MongoConnection to StringFormat[MongoConnection]

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

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

Ungrouped