crud

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ListParams

type ListParams struct {
	url.Values
	Page    int
	PerPage int
	Sort    string
	Filter  string
}

func (*ListParams) ToValues

func (params *ListParams) ToValues() url.Values

type ListResult

type ListResult[T any] struct {
	Page       int `json:"page"`
	PerPage    int `json:"perPage"`
	TotalItems int `json:"totalItems"`
	TotalPages int `json:"totalPages"`
	Items      []T `json:"items"`
}

type Service

type Service[T any] struct {
	*base.Service
	Collection string
}

func New

func New[T any](bs *base.Service, collection string) *Service[T]

func (*Service[T]) Create

func (s *Service[T]) Create(initBody func(req *resty.Request)) (result T, err error)

func (*Service[T]) Delete

func (s *Service[T]) Delete(id string, params *url.Values) (result base.Message, err error)

func (*Service[T]) FirstListItem added in v0.0.2

func (s *Service[T]) FirstListItem(params *ListParams) (record T, err error)

func (*Service[T]) FullList

func (s *Service[T]) FullList(batch int, params *ListParams) (list []T, err error)

func (*Service[T]) List

func (s *Service[T]) List(params *ListParams) (result ListResult[T], err error)

func (*Service[T]) One

func (s *Service[T]) One(id string, params *url.Values) (result T, err error)

func (*Service[T]) Update

func (s *Service[T]) Update(id string, initBody func(req *resty.Request)) (result T, err error)

Jump to

Keyboard shortcuts

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