public class RxJdbc extends Object implements org.jooby.Jooby.Module
rxjava-jdbc efficient execution, concise code, and functional composition of database calls using JDBC and RxJava Observable.
This module depends on Jdbc and Rx modules, make sure you read the doc of the
Jdbc
and Rx modules before using RxJdbc.
Database objectDataSource object
import org.jooby.rx.RxJdbc;
import org.jooby.rx.Rx;
{
// required by RxJdbc
use(new Rx());
use(new Jdbc());
use(new RxJdbc());
get("/reactive", req ->
req.require(Database.class)
.select("select name from something where id = :id")
.parameter("id", 1)
.getAs(String.class)
);
}
import org.jooby.rx.RxJdbc;
import org.jooby.rx.Rx;
{
// required by RxJdbc
use(new Rx());
use(new Jdbc("db.main"));
use(new RxJdbc("db.main"));
use(new Jdbc("db.audit"));
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!!!
| 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) |
public RxJdbc()
RxJdbc module.Copyright © 2017. All rights reserved.