This message can be used to ask for an r2d2 pg connection.
Generally, try to avoid it.
let conn = req.state().wdb.send(Conn{}).wait().ok().unwrap().unwrap();
let res= diesel::delete(users.filter(id.eq(uid))).execute(&conn);
Devised to be used for deleting things, but allows other RunQueryDsl queries as well.
let query = diesel::delete(users.filter(id.eq(uid)));
let del = DQuery {
query
};
let res = req.state().wdb.send(del).wait().ok().unwrap();
let query = users.filter(group_id.eq(group.id));
let query = query.order((lname.asc(), fname.asc()));
let select = SQuery {
select: query,
phantom: PhantomData::,
};
let res = req.state().rdb.send(select).wait().ok().unwrap();
Use the Read setting with a connection String to access a read-only db replica
Use the Write setting to udpate with a connection String to a writeable DB
There is a distinct r2d2 pool for each thread the DbExecutor actor runs on.
Therefore the pool is configured with max_size(3) and min_idle(Some(0)):
It creates a maximum of 3 connection per pool, starting with 0.