RPC
Chainable .rpc() calls in @xylex-group/athena — POST /gateway/rpc vs GET /rpc/{function}, filters, order, range, and select/single.
Use .rpc() to call Postgres functions with the same filter/order/pagination style as table reads.
- Default:
POST /gateway/rpc { get: true }: compatibilityGET /rpc/{function_name}
Examples
const { data, count } = await athena
.rpc("list_users", { role: "admin" }, { schema: "public", count: "exact" })
.eq("active", true)
.order("created_at", { ascending: false })
.range(0, 24)
.select(["id", "email"]);
const { data: user } = await athena
.rpc<{ id: number; email: string }>("list_users", { role: "admin" })
.single("id,email");
const { data: readOnlyUser } = await athena
.rpc<{ id: number; email: string }>("list_users", { role: "admin" }, { get: true, count: "planned", head: true })
.eq("id", 1)
.single("id,email");Table-returning functions can be narrowed before .single() / .maybeSingle():
const { data } = await athena.rpc("list_stored_countries").eq("id", 1).single();Chain support
.eq, .neq, .gt, .gte, .lt, .lte, .like, .ilike, .is, .in, .order, .limit, .offset, .range, .select, .single, .maybeSingle.
Options
schema, count (exact | planned | estimated), head, get — see AthenaRpcCallOptions.