repository

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SimplyRepository

type SimplyRepository[T easywalk.SimplyEntityInterface] struct {
	DB *gorm.DB
}

func (*SimplyRepository[T]) Create

func (r *SimplyRepository[T]) Create(data T) (uuid.UUID, error)

Create is a generic method for create operation @param data - pointer to entity @return uuid of created entity, error

func (*SimplyRepository[T]) Delete

func (r *SimplyRepository[T]) Delete(id uuid.UUID) (int64, error)

func (*SimplyRepository[T]) FindAll

func (r *SimplyRepository[T]) FindAll(mapFields map[string]any) ([]T, error)

func (*SimplyRepository[T]) Read

func (r *SimplyRepository[T]) Read(id uuid.UUID) (T, error)

func (*SimplyRepository[T]) ReadAll

func (r *SimplyRepository[T]) ReadAll() ([]T, error)

func (*SimplyRepository[T]) Update

func (r *SimplyRepository[T]) Update(id uuid.UUID, mapFields map[string]any) (int64, error)

type SimplyRepositoryInterface

type SimplyRepositoryInterface[T easywalk.SimplyEntityInterface] interface {
	Create(data T) (uuid.UUID, error)
	Update(id uuid.UUID, mapFields map[string]any) (int64, error)
	Delete(id uuid.UUID) (int64, error)

	// Query
	Read(id uuid.UUID) (T, error)
	ReadAll() ([]T, error)
	FindAll(mapFields map[string]any) ([]T, error)
}

func NewRepository added in v1.0.14

func NewRepository[T easywalk.SimplyEntityInterface](db *gorm.DB) SimplyRepositoryInterface[T]

NewSimplyRepository is a factory method for create new simplyRepository @param db - pointer to gorm DB @return pointer to simplyRepository @example

repo := NewSimplyRepository(db)

Jump to

Keyboard shortcuts

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