Skip to main content

fetch_one

Function fetch_one 

Source
pub async fn fetch_one<'a, T>(
    builder: QueryBuilder<'a, MySql>,
) -> Result<T, Error>
where T: for<'r> FromRow<'r, MySqlRow> + Unpin + Send + 'a,
Expand description

Fetch a single row and map it to a type

§Type Parameters

  • T - Type to map the row to, must implement FromRow trait

§Arguments

  • builder - QueryBuilder containing the query to execute

§Returns

Mapped type on success or an Error

获取单行数据并映射到类型

§类型参数

  • T - 要映射到的类型,必须实现 FromRow trait

§参数

  • builder - 包含要执行查询的 QueryBuilder

§返回值

成功时返回映射类型,失败时返回 Error