March Docs

BastionDepot

Bastion.Depot — database connection pool middleware.

Attaches a connection pool to the Conn assigns under the key "db", making it available to downstream handlers.

Usage:

conn
|> BastionDepot.with_pool(MyApp.Repo.pool())
|> MyApp.Router.route()

-- Retrieve in a handler:
let db = HttpServer.get_assign(conn, "db")
MyApp.Users.list_all(db)

Functions

fnwith_poolwith_pool(conn, pool)#

Store a pool reference in the conn assigns under "db".

This assigns the pool PID itself — it does NOT check out a connection.
Use `Depot.Middleware.with_pool/2` instead if you need a live connection
checked out per-request (with automatic checkin after the response).

This module is useful when you want to pass the pool down to handlers
that call `Pool.with_conn/2` themselves.