gorm_repo

package
v0.0.0-...-1bd3253 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func And

func And(specifications ...repository.Specification) repository.Specification

func Between

func Between[T any](field string, start T, end T) repository.Specification

func Equal

func Equal[T any](field string, value T) repository.Specification

func EqualWithJoinEqual

func EqualWithJoinEqual[T any](field string, value T, joins []string, preloads []string) repository.Specification

func GreaterOrEqual

func GreaterOrEqual[T comparable](field string, value T) repository.Specification

func GreaterThan

func GreaterThan[T comparable](field string, value T) repository.Specification

func IsNull

func IsNull(field string) repository.Specification

func JoinAndEqual

func JoinAndEqual(joins []string, preloads []string) repository.Specification

func LessOrEqual

func LessOrEqual[T comparable](field string, value T) repository.Specification

func LessThan

func LessThan[T comparable](field string, value T) repository.Specification

func NewAtomicRepository

func NewAtomicRepository(db *gorm.DB) *atomicRepository

func Not

func Or

func Or(specifications ...repository.Specification) repository.Specification

Types

type BaseRepository

type BaseRepository[E any] struct {
	// contains filtered or unexported fields
}

func New

func New[T any](db *gorm.DB) *BaseRepository[T]

func (*BaseRepository[E]) Delete

func (r *BaseRepository[E]) Delete(ctx context.Context, entity *E, specification repository.Specification) error

Delete record by specification and entity

func (*BaseRepository[E]) DeleteByID

func (r *BaseRepository[E]) DeleteByID(ctx context.Context, id uint) error

DeleteByID record by ID

func (*BaseRepository[E]) FindAll

func (r *BaseRepository[E]) FindAll(ctx context.Context, specification repository.Specification) ([]E, error)

FindAll retrieve a record by specification

func (*BaseRepository[E]) FindByID

func (r *BaseRepository[E]) FindByID(ctx context.Context, id uint) (E, error)

FindByID retrieve a record by id from a database

func (*BaseRepository[E]) FindOne

func (r *BaseRepository[E]) FindOne(ctx context.Context, specification repository.Specification) (E, error)

func (*BaseRepository[E]) InitializeTable

func (r *BaseRepository[E]) InitializeTable(ctx context.Context, entity *E) error

InitializeTable create table in db if doesn't exist

func (*BaseRepository[E]) Insert

func (r *BaseRepository[E]) Insert(ctx context.Context, entity *E) error

Insert create new record in the database

func (*BaseRepository[E]) Paginated

func (r *BaseRepository[E]) Paginated(ctx context.Context, specification repository.Specification, page, limit int) (repository.PaginatedResults[E], error)

Paginated select paginated data results

func (*BaseRepository[E]) Save

func (r *BaseRepository[E]) Save(ctx context.Context, entity *E) error

Save updates value in database. If value doesn't contain a matching primary key, value is inserted.

func (*BaseRepository[E]) Update

func (r *BaseRepository[E]) Update(ctx context.Context, entity *E) error

type WeatherHistoryRepository

type WeatherHistoryRepository struct {
	*BaseRepository[entity.WeatherHistory]
}

func NewWeatherHistoryRepository

func NewWeatherHistoryRepository(db *gorm.DB) *WeatherHistoryRepository

Jump to

Keyboard shortcuts

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