base

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 5 Imported by: 0

README

Base Repository And Mapper

Installation

go get -u github.com/Metadiv-Technology-Limited/base

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mapper

type Mapper[T any] struct {
	BeforeMap2Model func(from any) any
	AfterMap2Model  func(from any, to *T) *T
}

func (*Mapper[T]) Map2Model

func (m *Mapper[T]) Map2Model(from any, skipFields ...string) *T

func (*Mapper[T]) Map2Models

func (m *Mapper[T]) Map2Models(from any, skipFields ...string) []T

func (*Mapper[T]) MapModel2Model

func (m *Mapper[T]) MapModel2Model(from any, to *T, skipFields ...string) *T

type Repository

type Repository[T any] struct{}

func (*Repository[T]) Count

func (r *Repository[T]) Count(tx *gorm.DB, clause models.IClause) (int64, error)

func (*Repository[T]) Delete

func (r *Repository[T]) Delete(tx *gorm.DB, entity *T) error

func (*Repository[T]) DeleteAll

func (r *Repository[T]) DeleteAll(tx *gorm.DB, entities []T) error

func (*Repository[T]) DeleteBy

func (r *Repository[T]) DeleteBy(tx *gorm.DB, clause models.IClause) error

func (*Repository[T]) FindAll

func (r *Repository[T]) FindAll(tx *gorm.DB, clause models.IClause) ([]T, error)

func (*Repository[T]) FindAllComplex

func (r *Repository[T]) FindAllComplex(tx *gorm.DB, clause models.IClause, page models.IPagination, sort models.ISorting) ([]T, models.IPagination, error)

func (*Repository[T]) FindByID

func (r *Repository[T]) FindByID(tx *gorm.DB, id uint) (*T, error)

func (*Repository[T]) FindOne

func (r *Repository[T]) FindOne(tx *gorm.DB, clause models.IClause) (*T, error)

func (*Repository[T]) Save

func (r *Repository[T]) Save(tx *gorm.DB, entity *T) (*T, error)

func (*Repository[T]) SaveAll

func (r *Repository[T]) SaveAll(tx *gorm.DB, entities []T) ([]T, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL