From c62696dfd0373fd686d02fa93b7a28a16d36fda9 Mon Sep 17 00:00:00 2001 From: r1v3r Date: Thu, 27 Jan 2022 16:27:37 +0800 Subject: [PATCH] feat(do): implement WithResult method --- do.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/do.go b/do.go index 2aed48d1..55664e5e 100644 --- a/do.go +++ b/do.go @@ -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