Function select

Source
pub async fn select<T, F, R>(
    transaction: &Transaction<'_>,
    entity: T,
    to_model: F,
) -> Result<R, Error>
where T: SqlQuery<T> + SqlParams + Send + Sync + 'static, F: Fn(&Row) -> Result<R, Error> + Send + Sync + 'static, R: Send + 'static,
Expand description

§select

Retrieves a single record from the database within a transaction using a custom transformation function.

§Parameters

  • transaction: Transaction object
  • entity: Query parameter object (must implement SqlQuery and SqlParams traits)
  • to_model: Function to convert a Row object to the target object type

§Return Value

  • Result<R, Error>: On success, returns the transformed object; on failure, returns Error