Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyOptions ¶
ApplyOptions applies pagination, sorting, and filtering options to a GORM database query. It returns a modified gorm.DB instance with the applied options.
Types ¶
type CRUD ¶
CRUD is a generic struct that combines all CRUD operations. It embeds CreateFn, ReadFn, ListFn, UpdateFn, and DeleteFn to provide a complete set of handlers.
type CreateFn ¶
type CreateFn[T any] struct{}
CreateFn is a generic struct that implements the types.ServiceCreator interface.
func (*CreateFn[T]) Create ¶
func (r *CreateFn[T]) Create(resource types.Resource[T], _ *types.ServiceOptions, entity *T) (createdEntity *T, err error)
Create is a method of CreateFn that handles the creation of a resource. It interacts with a repository (e.g. a database) to persist the entity and returns the created entity and any error encountered.
type DeleteFn ¶
type DeleteFn[T any] struct{}
DeleteFn is a generic struct that implements the types.ServiceDeleter interface.
type ListFn ¶
type ListFn[T any] struct{}
ListFn is a generic struct that implements the types.ServiceLister interface.
func (*ListFn[T]) List ¶
func (r *ListFn[T]) List(resource types.Resource[T], options *types.ServiceOptions) (entities *[]T, meta *types.ServiceMeta, err error)
List is a method of ListFn that handles the listing of resources. It interacts with a repository (e.g. a database) to retrieve entities based on the provided options and returns the entities, metadata, and any error encountered.
type ReadFn ¶
type ReadFn[T any] struct{}
ReadFn is a generic struct that implements the types.ServiceReader interface.
func (*ReadFn[T]) Read ¶
func (r *ReadFn[T]) Read(resource types.Resource[T], _ *types.ServiceOptions, id string) (entity *T, err error)
Read is a method of ReadFn that handles the retrieval of a resource. It interacts with a repository (e.g. a database) to fetch the entity by its ID and returns the entity and any error encountered.
type UpdateFn ¶
type UpdateFn[T any] struct{}
UpdateFn is a generic struct that implements the types.ServiceUpdater interface.
func (*UpdateFn[T]) Update ¶
func (r *UpdateFn[T]) Update(resource types.Resource[T], options *types.ServiceOptions, id string, entity *T) (updatedEntity *T, err error)
Update is a method of UpdateFn that handles the updating of a resource. It interacts with a repository (e.g. a database) to update the entity either partially or fully based on the provided flag and returns the updated entity and any error encountered.