insert method

Inserts a single record into the table. Convenience method that wraps insertMany for single record insertion. This is useful when you only need to insert one row. Parameters:

  • conn - The active MySQL database connection
  • data - A map representing the row to insert. Keys should match field names, values should be QVar objects. Returns a MySqlResult containing information about the insert operation, including the generated ID if applicable. Example:
var result = await table.insert(conn, {
  'name': QVar('John Doe'),
  'email': QVar('john@example.com'),
});

Implementation

Future<SqlDatabaseResult> insert(
  DatabaseDriver conn,
  Map<String, QVar> data,
) async {
  return insertMany(conn, [data]);
}