Skip to content
Ravi Teja Gudapati edited this page Jan 17, 2019 · 4 revisions

Insert statement builder can be used to insert records into a table. The table to be inserted into is provided during construction of the Insert statement.

final insert = Insert('person');

Setting columns values

Use setValue method to set a column in the record.

final insert = Insert('person').setValue('age', 29);

Use setValues method to set multiple columns with a single call.

final insert = Insert('person').setValues({
  'name': 'Teja',
  'age': 29,
});

The above statement is equivalent to:

INSERT INTO person (name, age) VALUES ('Teja', 29);

Use setInt, ``setString, setBool` and `setDateTime` methods to set columns values in a type safe manner.

Executing the statement

Use the exec method to execute an insert statement.

final insert = Insert('person').setValues({
  'name': 'Teja',
  'age': 29,
});

await insert.exec(adapter);