Add callback support to a saving

v2 v2.0.8
Nikita Tokarchuk 4 years ago
parent 06f6f48f11
commit 87708fee04
  1. 14
      mongox/database/saveone.go

@ -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
}

Loading…
Cancel
Save