insertMany method

Future<MySqlResult> insertMany(
  1. MySQLConnection conn,
  2. List<Map<String, QVar>> data
)

Inserts multiple records into the table.

Executes a bulk INSERT statement to add multiple rows to the table in a single database operation, which is more efficient than individual inserts.

Parameters:

  • conn - The active MySQL database connection
  • data - A list of maps where each map represents a row to insert. Keys should match field names, values should be QVar objects.

Returns a MySqlResult containing information about the insert operation, including the number of affected rows.

Example:

var result = await table.insertMany(conn, [
  {'name': QVar('John'), 'email': QVar('john@example.com')},
  {'name': QVar('Jane'), 'email': QVar('jane@example.com')},
]);

Implementation

Future<MySqlResult> insertMany(
  MySQLConnection conn,
  List<Map<String, QVar>> data,
) async {
  String sql = Sqler().insert(QField(name), data).toSQL();
  return execute(conn, sql);
}