Your Question

` // batch size 100 result := db.Where("processed = ?", false).FindInBatches(&results, 100, func(tx *gorm.DB, batch int) error { // is this necessary to judge tx.Error if tx.Error != nil { return tx.Error }

for _, result := range results {
  // batch processing found records
}


// returns error will stop future batches
return nil

})

result.Error // returned error result.RowsAffected // processed records count in all batches ` with out the judge of tx.Error inside handler function, can we get result.Error!=nil outside, if one of the queries fail?

Expected answer

Comment From: a631807682

Yes you should, without the judge of tx.Error is means that you want to ignore this error in result.