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 }
- Alphabetic
- By Inheritance
- MongoConnection
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
+(other: String): String
- Implicit
- This member is added by an implicit conversion from MongoConnection to any2stringadd[MongoConnection] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
-
def
->[B](y: B): (MongoConnection, B)
- Implicit
- 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()
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
active: Boolean
Returns true if the connection has not been killed.
Returns true if the connection has not been killed.
- Annotations
- @inline()
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
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
- Annotations
- @SuppressWarnings()
- See also
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
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) }
-
def
database(name: String, failoverStrategy: FailoverStrategy = options.failoverStrategy)(implicit ec: ExecutionContext): Future[DB]
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()
-
def
ensuring(cond: (MongoConnection) ⇒ Boolean, msg: ⇒ Any): MongoConnection
- Implicit
- This member is added by an implicit conversion from MongoConnection to Ensuring[MongoConnection] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: (MongoConnection) ⇒ Boolean): MongoConnection
- Implicit
- This member is added by an implicit conversion from MongoConnection to Ensuring[MongoConnection] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean, msg: ⇒ Any): MongoConnection
- Implicit
- This member is added by an implicit conversion from MongoConnection to Ensuring[MongoConnection] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean): MongoConnection
- Implicit
- This member is added by an implicit conversion from MongoConnection to Ensuring[MongoConnection] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
formatted(fmtstr: String): String
- Implicit
- 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()
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- MongoConnection → AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
→[B](y: B): (MongoConnection, B)
- Implicit
- This member is added by an implicit conversion from MongoConnection to ArrowAssoc[MongoConnection] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc