mirror of
https://github.com/mainnika/mongox-go-driver.git
synced 2026-05-22 15:53:36 +00:00
Add callback support to a saving
This commit is contained in:
@@ -32,10 +32,22 @@ func (d *Database) SaveOne(source interface{}, filters ...interface{}) (err erro
|
||||
protected.V = time.Now().Unix()
|
||||
}
|
||||
|
||||
defer composed.OnClose().Invoke(ctx, source)
|
||||
|
||||
result := collection.FindOneAndReplace(ctx, composed.M(), source, opts)
|
||||
if result.Err() != nil {
|
||||
return result.Err()
|
||||
}
|
||||
|
||||
return result.Decode(source)
|
||||
err = result.Decode(source)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = composed.OnDecode().Invoke(ctx, source)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user