insertMany method
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 connectiondata- 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<SqlDatabaseResult> insertMany(
DatabaseDriver conn,
List<Map<String, QVar>> data,
) async {
String sql = Sqler().insert(QField(name), data).toSQL();
return conn.executeString(sql);
}