Documentation ¶
Index ¶
- type Repo
- func (r Repo[C]) Count(ctx context.Context, query string, args ...any) (int64, error)
- func (r Repo[C]) Create(ctx context.Context, u *C, returning ...string) (*C, error)
- func (r Repo[C]) Create2(ctx context.Context, u *[]C, returning ...string) (*[]C, error)
- func (r Repo[C]) CreateOrUpdate(ctx context.Context, u *C, onConflict []interface{}, doUpdates []interface{}, ...) (*C, error)
- func (r Repo[C]) DB() *gorm.DB
- func (r Repo[C]) Delete(ctx context.Context, query string, args ...any) error
- func (r Repo[C]) Error(ctx context.Context, err error) error
- func (r Repo[C]) Exists(ctx context.Context, field string, value interface{}, excludeField string, ...) error
- func (r Repo[C]) FieldOrderBy() clause.FieldOrderBy
- func (r Repo[C]) FieldSearchable() clause.FieldSearchable
- func (r Repo[C]) Find(ctx context.Context, query string, args ...any) (*C, error)
- func (r Repo[C]) FindById(ctx context.Context, id int) (*C, error)
- func (r Repo[C]) FirstOrCreate(ctx context.Context, u *C, returning string, query string, args ...any) (*C, error)
- func (r Repo[C]) Joins(models ...string) Repo[C]
- func (r Repo[C]) List(ctx context.Context, f *model.Filter, query string, args ...any) ([]C, error)
- func (r Repo[C]) Model() C
- func (r Repo[C]) Omit(columns ...string) Repo[C]
- func (r Repo[C]) OrderBy(orderBy []clause.ExpressionOrderBy) (Repo[C], error)
- func (r Repo[C]) Paginate(ctx context.Context, p *model.Meta[C], query string, args ...any) error
- func (r Repo[C]) PluckIDs(ctx context.Context, query string, args ...any) ([]int, error)
- func (r Repo[C]) QuoteTo(str string) string
- func (r Repo[C]) SetDB(db *gorm.DB) Repo[C]
- func (r Repo[C]) Trx(db *gorm.DB) Repo[C]
- func (r Repo[C]) Update(ctx context.Context, u *C, selects []interface{}, query string, args ...any) error
- func (r Repo[C]) Update2(ctx context.Context, u *[]C, selects []interface{}, query string, args ...any) error
- func (r Repo[C]) UpdateMap(ctx context.Context, u map[string]interface{}, query string, args ...any) error
- func (r Repo[C]) Where(where *clause.ExpressionWhere) (Repo[C], error)
- func (r Repo[C]) With(models ...string) Repo[C]
- type Repository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repo ¶
func NewRepository ¶
func NewRepository[C model.Model](db *gorm.DB, fieldSearchable clause.FieldSearchable, fieldOrderBy clause.FieldOrderBy) Repo[C]
func (Repo[C]) CreateOrUpdate ¶
func (Repo[C]) FieldOrderBy ¶ added in v2.3.0
func (r Repo[C]) FieldOrderBy() clause.FieldOrderBy
func (Repo[C]) FieldSearchable ¶
func (r Repo[C]) FieldSearchable() clause.FieldSearchable
func (Repo[C]) FirstOrCreate ¶
func (Repo[C]) OrderBy ¶
func (r Repo[C]) OrderBy(orderBy []clause.ExpressionOrderBy) (Repo[C], error)
type Repository ¶
type Repository[T any, C model.Model] interface { Trx(db *gorm.DB) T With(models ...string) T Joins(models ...string) T Omit(columns ...string) T Find(ctx context.Context, query string, args ...any) (*C, error) FindById(ctx context.Context, id int) (*C, error) Delete(ctx context.Context, query string, args ...any) error Create(ctx context.Context, u *C, returning ...string) (*C, error) Create2(ctx context.Context, u *[]C, returning ...string) (*[]C, error) CreateOrUpdate(ctx context.Context, u *C, onConflict []interface{}, doUpdates []interface{}, doCreates []interface{}, returning ...string) (*C, error) FirstOrCreate(ctx context.Context, u *C, returning string, query string, args ...any) (*C, error) Update(ctx context.Context, u *C, selects []interface{}, query string, args ...any) error Update2(ctx context.Context, u *[]C, selects []interface{}, query string, args ...any) error UpdateMap(ctx context.Context, u map[string]interface{}, query string, args ...any) error Count(ctx context.Context, query string, args ...any) (int64, error) List(ctx context.Context, f *model.Filter, query string, args ...any) ([]C, error) Paginate(ctx context.Context, p *model.Meta[C], query string, args ...any) error PluckIDs(ctx context.Context, query string, args ...any) ([]int, error) DB() *gorm.DB }
Click to show internal directories.
Click to hide internal directories.