WithCollection

Functions to work with a Mongo collection (provided DB functions).

class Object
trait Matchable
class Any
object AcolyteDSL.type

Value members

Concrete methods

def withCollection[A, B](conParam: => A, name: String)(f: BSONCollection => B)(implicit d: AsyncDriver, m: ConnectionManager[A], ec: ExecutionContext, compose: ComposeWithCompletion[B]): Outer

Works with specified collection from MongoDB "acolyte" resolved using given driver initialized with Acolyte for ReactiveMongo (should not be used with other driver instances). Driver and associated resources are released after the function f the result Future is completed.

Works with specified collection from MongoDB "acolyte" resolved using given driver initialized with Acolyte for ReactiveMongo (should not be used with other driver instances). Driver and associated resources are released after the function f the result Future is completed.

Value parameters:
conParam

Connection manager parameter (see ConnectionManager)

f

Function applied to resolved Mongo collection

import scala.concurrent.{ ExecutionContext, Future }
import reactivemongo.api.AsyncDriver
import acolyte.reactivemongo.{ AcolyteDSL, ConnectionManager }
// handler: ConnectionHandler
def s[T: ConnectionManager](handler: => T)(
 implicit ec: ExecutionContext, d: AsyncDriver): Future[String] =
 AcolyteDSL.withCollection(handler, "colName") { _ =>
   "Result"
 }
name

the name of the collection

See also:

AcolyteDSL.withDB[A,B]

def withCollection[T](con: => MongoConnection, name: String)(f: BSONCollection => T)(implicit ec: ExecutionContext, compose: ComposeWithCompletion[T]): Outer

Works with specified collection from MongoDB "acolyte" resolved using given connection.

Works with specified collection from MongoDB "acolyte" resolved using given connection.

Value parameters:
con

Previously initialized connection

f

Function applied to resolved Mongo collection

import scala.concurrent.{ ExecutionContext, Future }
import reactivemongo.api.AsyncDriver
import acolyte.reactivemongo.{ AcolyteDSL, ConnectionHandler }
// handler: ConnectionHandler
def s(handler: ConnectionHandler)(
 implicit ec: ExecutionContext, d: AsyncDriver): Future[String] =
 AcolyteDSL.withConnection(handler) { con =>
   AcolyteDSL.withCollection(con, "colName") { _ =>
     "Result"
   }
 }
name

the name of the collection

See also:

WithDriver.withDB[T]

def withCollection[T](db: DB, name: String)(f: BSONCollection => T): T

Works with specified collection from MongoDB "acolyte" resolved using given Mongo DB.

Works with specified collection from MongoDB "acolyte" resolved using given Mongo DB.

Value parameters:
db

Previously resolved Mongo DB

f

Function applied to resolved Mongo collection

import scala.concurrent.{ ExecutionContext, Future }
import reactivemongo.api.AsyncDriver
import acolyte.reactivemongo.{ AcolyteDSL, ConnectionHandler }
def s(handler: ConnectionHandler)(
 implicit ec: ExecutionContext, d: AsyncDriver): Future[String] =
 AcolyteDSL.withDB(handler) { db =>
   AcolyteDSL.withCollection(db, "colName") { _ =>
     "Result"
   }
 }
name

the name of the collection