createReturning method

Future<$Dataclass> createReturning(
  1. Insertable<$Dataclass> f(
    1. $CreateCompanionCallback o
    ), {
  2. InsertMode? mode,
  3. UpsertClause<$Table, $Dataclass>? onConflict,
})

Inserts a row into the table and returns it.

Depending on the InsertMode or the DoUpdate onConflict clause, the insert statement may not actually insert a row into the database. Since this function was declared to return a non-nullable row, it throws an exception in that case. Use createReturningOrNull when performing an insert with an insert mode like InsertMode.insertOrIgnore or when using a DoUpdate with a where clause clause.

Implementation

Future<$Dataclass> createReturning(
    Insertable<$Dataclass> Function($CreateCompanionCallback o) f,
    {InsertMode? mode,
    UpsertClause<$Table, $Dataclass>? onConflict}) {
  return $state.db.into($state._tableAsTableInfo).insertReturning(
      f($state._createCompanionCallback),
      mode: mode,
      onConflict: onConflict);
}