Tests
This commit is contained in:
@ -8,7 +8,8 @@ import (
|
||||
)
|
||||
|
||||
type GetOptions struct {
|
||||
Only *[]string
|
||||
Only *[]string
|
||||
RaiseError *bool
|
||||
}
|
||||
|
||||
type GetMethod[T schema.Tabler] struct {
|
||||
@ -34,9 +35,12 @@ func (m GetMethod[T]) Get(filter interface{}, options *GetOptions) (*T, error) {
|
||||
}
|
||||
|
||||
result := query.First(&model)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
if result.Error == nil {
|
||||
return &model, nil
|
||||
}
|
||||
|
||||
return &model, nil
|
||||
if options != nil && options.RaiseError != nil && *options.RaiseError {
|
||||
return nil, result.Error
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user