Function insert

Source
pub async fn insert<T, P: for<'a> FromSql<'a> + Send + Sync>(
    transaction: &Transaction<'_>,
    entity: T,
) -> Result<P, Error>
where T: SqlCommand + SqlParams + Send + Sync + 'static,
Expand description

§insert

Inserts a new record into the database within a transaction.

§Parameters

  • transaction: Transaction object
  • entity: Data object to be inserted (must implement SqlCommand and SqlParams traits)

§Return Value

  • Result<P, Error>: On success, returns the generated primary key; on failure, returns Error