previewUpsertMany method

StatementPreview previewUpsertMany(
  1. List<Object> inputs, {
  2. List<String>? uniqueBy,
  3. List<String>? updateColumns,
  4. JsonUpdateBuilder<T>? jsonUpdates,
})

Returns the statement preview for upserting items.

Example:

final users = [
  $User(id: 1, name: 'John Doe', email: 'john@example.com'),
  {'name': 'Jane Doe', 'email': 'jane@example.com'},
];
final preview = repository.previewUpsertMany(users, uniqueBy: ['email']);

Implementation

StatementPreview previewUpsertMany(
  List<Object> inputs, {
  List<String>? uniqueBy,
  List<String>? updateColumns,
  JsonUpdateBuilder<T>? jsonUpdates,
}) {
  if (inputs.isEmpty) {
    throw ArgumentError.value(
      inputs,
      'inputs',
      'previewUpsertMany requires inputs',
    );
  }
  final query = _requireQuery('previewUpsertMany');
  final plan = query.previewUpsertPlan(
    inputs,
    uniqueBy: uniqueBy,
    updateColumns: updateColumns,
    jsonUpdates: jsonUpdates,
    returning: false,
  );
  return describeMutation(plan);
}