Skip to content

Commit

Permalink
feat(do): implement WithResult method
Browse files Browse the repository at this point in the history
  • Loading branch information
tr1v3r committed Jan 28, 2022
1 parent b4c83a4 commit c62696d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions do.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,12 @@ func (d *DO) ScanRows(rows *sql.Rows, dest interface{}) error {
return d.db.Model(d.newResultPointer()).ScanRows(rows, dest)
}

func (d DO) WithResult(fc func(tx Dao)) ResultInfo {
d.db = d.db.Set("", "")
fc(&d)
return ResultInfo{RowsAffected: d.db.RowsAffected, Error: d.db.Error}
}

func (d *DO) newResultPointer() interface{} {
if d.modelType == nil {
return nil
Expand Down

0 comments on commit c62696d

Please sign in to comment.