Documentation ¶
Index ¶
- Variables
- func Capitalize(str string) string
- func Close(db io.Closer)
- func ConvertToColumnCase(fieldName string) string
- func HasError(err error) bool
- func NoError(err error) bool
- func P[T any](t T) *T
- func ReadError(err error) *string
- func ReadValue(value reflect.Value) any
- func RollbackFor(tc TransactionContext, origin error) error
- func ToSnakeCase(fieldName string) string
- func TransactionCallback(tc TransactionContext, callback func(tc TransactionContext) error) (err error)
- type ColumnMetadata
- type DataAccess
- type Entity
- type Int64Id
- type IntId
- type PageList
- type PageQuery
- type Query
- type Response
- type RollbackError
- type TransactionContext
- type TransactionManager
- type TxDataAccess
Constants ¶
This section is empty.
Variables ¶
View Source
var SortRgx = regexp.MustCompile("(?i)(\\w+)(,(asC|dEsc))?;?")
View Source
var SuffixRgx = regexp.MustCompile("(" + SuffixStr + ")$")
View Source
var SuffixStr = "Gt|Ge|Lt|Le|Not|Ne|Eq|Null|NotIn|In|Like|NotLike|Contain|NotContain|Start|NotStart|End|NotEnd|Rx"
Functions ¶
func Capitalize ¶ added in v0.2.2
func ConvertToColumnCase ¶
func RollbackFor ¶
func RollbackFor(tc TransactionContext, origin error) error
func ToSnakeCase ¶
func TransactionCallback ¶
func TransactionCallback(tc TransactionContext, callback func(tc TransactionContext) error) (err error)
Types ¶
type ColumnMetadata ¶
type ColumnMetadata struct { Field reflect.StructField IsId bool ColumnName string }
func BuildColumnMetas ¶
func BuildColumnMetas(structType reflect.Type) []ColumnMetadata
type DataAccess ¶
type DataAccess[E Entity] interface { Get(ctx context.Context, id any) (*E, error) Delete(ctx context.Context, id any) (int64, error) Query(ctx context.Context, query Query) ([]E, error) Count(ctx context.Context, query Query) (int64, error) DeleteByQuery(ctx context.Context, query Query) (int64, error) Page(ctx context.Context, query Query) (PageList[E], error) Create(ctx context.Context, entity *E) (int64, error) CreateMulti(ctx context.Context, entities []E) (int64, error) Update(ctx context.Context, entity E) (int64, error) Patch(ctx context.Context, entity E) (int64, error) PatchByQuery(ctx context.Context, entity E, query Query) (int64, error) }
type PageQuery ¶
type PageQuery struct { PageNumber *int `json:"page,omitempty"` PageSize *int `json:"size,omitempty"` Sort *string `json:"sort,omitempty"` }
func (PageQuery) CalcOffset ¶
func (PageQuery) GetPageNumber ¶
func (PageQuery) GetPageSize ¶
func (PageQuery) NeedPaging ¶
type RollbackError ¶
func (*RollbackError) Error ¶
func (e *RollbackError) Error() string
func (*RollbackError) Unwrap ¶
func (e *RollbackError) Unwrap() error
type TransactionContext ¶
type TransactionManager ¶
type TransactionManager interface { GetClient() any StartTransaction(ctx context.Context) (TransactionContext, error) SubmitTransaction(ctx context.Context, callback func(tc TransactionContext) error) error }
type TxDataAccess ¶
type TxDataAccess[E Entity] interface { TransactionManager DataAccess[E] }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.