Documentation ¶
Index ¶
- func DSN(config *config.DatabaseConfig) string
- func FindUsingTemplate[T any, C any](ctx context.Context, gorm *gorm.DB, ...) (*T, error)
- func FindUsingTemplatePageable[T any, C any](ctx context.Context, gorm *gorm.DB, ...) (*models.Page[*T], error)
- type Database
- type EntityRepository
- type Repository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DSN ¶
func DSN(config *config.DatabaseConfig) string
func FindUsingTemplate ¶
func FindUsingTemplate[T any, C any]( ctx context.Context, gorm *gorm.DB, queryTemplateEngine sqlTemplate.QueryTemplateEngine, namespace string, name string, criteriaAndPagination *models.CriteriaAndPagination[C], ) (*T, error)
FindUsingTemplate cannot be part of the repository until https://github.com/golang/go/issues/49085 is fixed.
func FindUsingTemplatePageable ¶
func FindUsingTemplatePageable[T any, C any]( ctx context.Context, gorm *gorm.DB, queryTemplateEngine sqlTemplate.QueryTemplateEngine, namespace string, name string, criteriaAndPagination *models.CriteriaAndPagination[C], ) (*models.Page[*T], error)
FindUsingTemplatePageable cannot be part of the repository until https://github.com/golang/go/issues/49085 is fixed.
Types ¶
type EntityRepository ¶
type EntityRepository[T common.EntityConstraint] interface { WithTx(tx *gorm.DB) EntityRepository[T] TransactWithDefaultRetry(operation func(tx *gorm.DB) error) error FindOneByID(ctx context.Context, id uint) (entity *T, err error) FindOneByIDForUpdate(ctx context.Context, id uint) (entity *T, err error) FindAll(ctx context.Context, pagination *models.Pagination) (page *models.Page[*T], err error) FindAllByCriteria( ctx context.Context, criteriaAndPagination any, pagination *models.Pagination) (page *models.Page[*T], err error) Create(ctx context.Context, entity *T) (*T, error) Save(ctx context.Context, entity *T) (*T, error) DeleteByID(ctx context.Context, id uint) error Count(ctx context.Context) (int64, error) Gorm() *gorm.DB WrapError(err error) error }
func NewEntityRepository ¶
func NewEntityRepository[T common.EntityConstraint]( database Database, entity T, logger logger.Logger, config *config.AppConfig, ) EntityRepository[T]
type Repository ¶
type Repository interface { WithTx(tx *gorm.DB) Repository RawSQL(ctx context.Context, sql string, values ...any) error Gorm() *gorm.DB WrapError(err error) error }
func NewRepository ¶
func NewRepository( database Database, logger logger.Logger, config *config.AppConfig, queryTemplateEngine sqlTemplate.QueryTemplateEngine, ) Repository
Click to show internal directories.
Click to hide internal directories.