public class RxJdbc extends Jdbc
rxjava-jdbc efficient execution, concise code, and functional composition of database calls using JDBC and RxJava Observable.
This module depends on Jdbc module, make sure you read the doc of the Jdbc
module.
Database objectDataSource object
import org.jooby.rx.RxJdbc;
import org.jooby.rx.Rx;
{
use(new RxJdbc());
get("/reactive", req ->
req.require(Database.class)
.select("select name from something where id = :id")
.parameter("id", 1)
.getAs(String.class)
).map(Rx.rx());
}
The Rx.rx() mapper converts rx observables to Deferred
instances. More at Rx.
import org.jooby.rx.RxJdbc;
import org.jooby.rx.Rx;
{
use(new RxJdbc("db.main"));
use(new RxJdbc("db.audit"));
get("/", req ->
Databse db = req.require("db.main", Database.class);
Databse audit = req.require("db.audit", Database.class);
// ...
).map(Rx.rx());
}
For more details on how to configure the Hikari datasource, please check the jdbc
module
Happy coding!!!
dbName, dbtype, DEFAULT_DB| Constructor and Description |
|---|
RxJdbc()
Creates a new
RxJdbc module. |
RxJdbc(String name)
Creates a new
RxJdbc module. |
| Modifier and Type | Method and Description |
|---|---|
void |
configure(org.jooby.Env env,
com.typesafe.config.Config config,
com.google.inject.Binder binder) |
config, dataSource, keyspublic RxJdbc()
RxJdbc module.Copyright © 2016. All rights reserved.