Search code examples
gogo-gorm

Gorm Update and Get the Updated Rows in a single operation?


Is there any way to get the rows that have been updated using the update command in Gorm, using a single operation.


Solution

  • I know this is like a million years old but for the sake of completion here's the Gorm way of doing it - clauses.

        result := r.Gdb.Model(&User{}).Clauses(clause.Returning{}).Where("id = ?", "000-000-000").Updates(content)
    

    Ref: Gorm Returning Data From Modified Rows