insert method Null safety

Future<InstanceType> insert()

Inserts an InstanceType into the underlying database.

The Query must have its values or valueMap property set. This operation will insert a row with the data supplied in those fields to the database in context. The return value is a Future that completes with the newly inserted InstanceType. Example:

  var q = Query<User>() = "Joe";
  var newUser = await q.insert();

If the InstanceType has properties with Validate metadata, those validations will be executed prior to sending the query to the database.

The method guaranties that exactly one row will be inserted and returned or an exception will be thrown and the row will not be written to the database.


Future<InstanceType> insert();