Skip to main content

insert

Function insert 

Source
pub async fn insert<'e, E, DB, D, Ex>(
    dialect: &D,
    executor: Ex,
    entity: &E,
) -> Result<E, FletchError>
where E: Entity + for<'r> FromRow<'r, <DB as Database>::Row> + Send + Unpin, D: Dialect, DB: Database + DatabaseBindable, Ex: Executor<'e, Database = DB> + Send,
Expand description

Insert a new entity and return it.

The id column is excluded from the INSERT statement so that the database can assign an autoincrement primary key. On engines without RETURNING, the inserted row is re-selected via LAST_INSERT_ID().