/// Looks up a row by ID and returns a future that resolves an
/// `Option<Self>`. Returns `None` if and a record with the corresponding ID
/// cannot be found and `Some` if it exists.
///
/// # Example
///
/// ```rust
/// # sqlx_crud::doctest_setup! { |pool| {
/// use sqlx_crud::Crud;
///
/// let user: Option<User> = User::by_id(&pool, 1).await?;
/// assert!(user.is_some());
/// # }}
/// ```
Looks up a row by ID and returns a future that resolves an
`Option`. Returns `None` if and a record with the corresponding ID
cannot be found and `Some` if it exists.
Looks up a row by ID and returns a future that resolves an ` Option ` . Returns ` None ` if and a record with the corresponding ID cannot be found and ` Some ` if it exists .
fn by_id(pool: E, id: <Self as Schema>::Id) -> CrudFut<'e, Option<Self>> {
        Box::pin(
            sqlx::query_as::<E::Database, Self>(<Self as Schema>::select_by_id_sql())
                .bind(id)
                .fetch_optional(pool),
        )
    }
fn by_id ( pool : E , id : < Self as Schema > :: Id ) -> CrudFut < ' e , Option < Self > > { Box :: pin ( sqlx :: query_as :: < E :: Database , Self > ( < Self as Schema > :: select_by_id_sql ( ) ) . bind ( id ) . fetch_optional ( pool ) , ) }
Looks up a row by ID and returns a future that resolves an
`Option<Self>`.
Looks up a row by ID and returns a future that resolves an ` Option<Self > ` .
pool
E
id
<Self as Schema>::Id
example
None
sqlx_crud::doctest_setup! { |pool| {
use sqlx_crud::Crud.

let user: Option = User::by_id(&pool, 1).await?;
assert!(user.is_some()).
use sqlx_crud :: Crud . let user : Option = User :: by_id ( &pool 1 ) . await? ; assert! ( user . is_some () ) .
}}
None