Returns unmanaged driver.
Returns unmanaged driver. You will have to close it by yourself.
Creates an empty connection handler.
Creates an empty connection handler.
import acolyte.reactivemongo.AcolyteDSL def foo = AcolyteDSL.handle
Creates a connection handler with given query handler, but no write handler.
Creates a connection handler with given query handler, but no write handler.
import scala.concurrent.ExecutionContext import acolyte.reactivemongo.AcolyteDSL.{ withConnection, withDriver, handleQuery } import acolyte.reactivemongo.{ PreparedResponse, Request } def aResponse: PreparedResponse = ??? def foo(implicit ec: ExecutionContext) = withDriver { implicit d => withConnection(handleQuery { (_: Request) => aResponse }) { _ => // work with connection (e.g. call you function using Mongo) "Value" } }
Creates a connection handler with given write handler, but no query handler.
Creates a connection handler with given write handler, but no query handler.
import scala.concurrent.ExecutionContext import reactivemongo.api.AsyncDriver import acolyte.reactivemongo.AcolyteDSL.{ withConnection, withDriver, handleWrite } import acolyte.reactivemongo.{ Request, WriteOp, PreparedResponse } def aResponse: PreparedResponse = ??? def foo(implicit ec: ExecutionContext) = withDriver { implicit d: AsyncDriver => withConnection(handleWrite { (_: WriteOp, _: Request) => aResponse }) { _ => // work with connection (e.g. call you function using Mongo) "Value" } }
Works with specified collection from MongoDB "acolyte" resolved using given Mongo DB.
Works with specified collection from MongoDB "acolyte" resolved using given Mongo DB.
Previously resolved Mongo DB
the name of the collection
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" } }
Works with specified collection from MongoDB "acolyte" resolved using given connection.
Works with specified collection from MongoDB "acolyte" resolved using given connection.
Previously initialized connection
the name of the collection
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" } }
WithDriver.withDB[T]
Works with specified collection from MongoDB "acolyte" resolved using given driver initialized with Acolyte for ReactiveMongo (should not be used with other driver instances).
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.
Connection manager parameter (see ConnectionManager)
the name of the collection
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" }
AcolyteDSL.withDB[A,B]
Works with connection with options appropriate for a driver initialized using Acolyte for ReactiveMongo (should not be used with other driver instances).
Works with connection with options appropriate for a driver
initialized using Acolyte for ReactiveMongo
(should not be used with other driver instances).
Connection is closed after the result Future
is completed.
the connection manager parameter (see ConnectionManager)
the function applied to initialized driver
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.{ MongoConnection, AsyncDriver } import acolyte.reactivemongo.{ AcolyteDSL, ConnectionHandler } // handler: ConnectionHandler def s(handler: ConnectionHandler)( implicit ec: ExecutionContext, d: AsyncDriver): Future[String] = AcolyteDSL.withConnection(handler) { (_: MongoConnection) => "Result" }
Works with a Mongo database resolved using given driver initialized using Acolyte for ReactiveMongo (should not be used with other driver instances).
Works with a Mongo database resolved using given driver initialized using Acolyte for ReactiveMongo (should not be used with other driver instances).
a previously initialized connection
the name of database
the function applied to initialized Mongo DB
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.{ DB, AsyncDriver } import acolyte.reactivemongo.{ AcolyteDSL, ConnectionHandler } // handler: ConnectionHandler def s(handler: ConnectionHandler)( implicit ec: ExecutionContext, d: AsyncDriver): Future[String] = AcolyteDSL.withConnection(handler) { con => AcolyteDSL.withDB(con, "my_db") { (_: DB) => "Result" } }
AcolyteDSL.withConnection
Works with Mongo database (named "acolyte") resolved using given driver initialized using Acolyte for ReactiveMongo (should not be used with other driver instances).
Works with Mongo database (named "acolyte") resolved using given driver initialized using Acolyte for ReactiveMongo (should not be used with other driver instances).
a previously initialized connection
the function applied to initialized Mongo DB
import scala.concurrent.ExecutionContext import reactivemongo.api.{ DB, AsyncDriver } import acolyte.reactivemongo.{ AcolyteDSL, ConnectionHandler } def s(handler: ConnectionHandler)( implicit ec: ExecutionContext, d: AsyncDriver) = AcolyteDSL.withConnection(handler) { con => AcolyteDSL.withDB(con) { (_: DB) => "Result" } }
AcolyteDSL.withConnection
Works with a Mongo database resolved using given driver initialized using Acolyte for ReactiveMongo (should not be used with other driver instances).
Works with a Mongo database resolved using given driver
initialized using 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.
the connection manager parameter (see ConnectionManager)
the name of database
the name of the replica set (if some)
the function applied to initialized Mongo DB
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.{ DB, AsyncDriver } import acolyte.reactivemongo.{ AcolyteDSL, ConnectionHandler } def s(handler: ConnectionHandler)( implicit ec: ExecutionContext, d: AsyncDriver): Future[String] = AcolyteDSL.withDB(handler, "my_db") { (_: DB) => "Result" }
AcolyteDSL.withConnection
Works with a Mongo database (named "acolyte") resolved using given driver initialized using Acolyte for ReactiveMongo (should not be used with other driver instances).
Works with a Mongo database (named "acolyte") resolved using given driver
initialized using 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.
the connection manager parameter (see ConnectionManager)
the function applied to initialized Mongo DB
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.{ DB, AsyncDriver } import acolyte.reactivemongo.{ AcolyteDSL, ConnectionHandler } def s(handler: ConnectionHandler)( implicit ec: ExecutionContext, d: AsyncDriver): Future[String] = AcolyteDSL.withDB(handler) { (_: DB) => "Result" }
AcolyteDSL.withConnection
Works with MongoDB driver configured with Acolyte handlers.
Works with MongoDB driver configured with Acolyte handlers.
Driver and associated resources are released
after the function f
the result Future
is completed.
the function applied to initialized driver
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.AsyncDriver import acolyte.reactivemongo.AcolyteDSL // handler: ConnectionHandler def s(implicit ec: ExecutionContext): Future[String] = AcolyteDSL.withDriver { (_: AsyncDriver) => "Result" }
Works with a MongoDB driver handling only queries,
using given query handler
.
Works with a MongoDB driver handling only queries,
using given query handler
.
Driver and associated resources are released
after the function f
the result Future
is completed.
Query handler
import scala.concurrent.ExecutionContext import reactivemongo.api.{ AsyncDriver, MongoConnection } import acolyte.reactivemongo.{ AcolyteDSL, PreparedResponse, Request } def aResponse: PreparedResponse = ??? def foo(implicit ec: ExecutionContext, d: AsyncDriver) = AcolyteDSL.withQueryHandler({ (_: Request) => aResponse }) { (_: MongoConnection) => "aResult" }
Works with a MongoDB driver handling only queries,
and returning given result
for all of them.
Works with a MongoDB driver handling only queries,
and returning given result
for all of them.
Driver and associated resources are released
after the function f
the result Future
is completed.
Query result
Works with a MongoDB driver handling only write operations,
using given write handler
.
Works with a MongoDB driver handling only write operations,
using given write handler
.
Driver and associated resources are released
after the function f
the result Future
is completed.
Writer handler
import scala.concurrent.ExecutionContext import reactivemongo.api.AsyncDriver import acolyte.reactivemongo.{ AcolyteDSL, PreparedResponse, Request, WriteOp } def aResp: PreparedResponse = ??? def foo(implicit ec: ExecutionContext, d: AsyncDriver) = AcolyteDSL.withWriteHandler({ (_: WriteOp, _: Request) => aResp }) { _ => "aResult" }
Works with a MongoDB driver handling only write operations,
and returning given result
for all of them.
Works with a MongoDB driver handling only write operations,
and returning given result
for all of them.
Driver and associated resources are released
after the function f
the result Future
is completed.
Acolyte DSL for ReactiveMongo.