mockrepository

package
v0.0.7-alpha Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorCreateIfNotExistsByProvider = false
View Source
var FakeRepoErrors = map[string]error{}

Functions

func ByID

func ByID[E entities.Entity](ctx context.Context, name string, slice []*E, id int) (*E, error)

Types

type CommentRepository

type CommentRepository struct {
	*Repository[entities.Comment]
}

func (*CommentRepository) Count

func (m *CommentRepository) Count(ctx context.Context, filters ...*entities.CommentFilter) (int, error)

func (*CommentRepository) Find

func (m *CommentRepository) Find(ctx context.Context, filters ...*entities.CommentFilter) ([]*entities.Comment, error)

func (*CommentRepository) FindWithPost

func (m *CommentRepository) FindWithPost(ctx context.Context, filters ...*entities.CommentFilter) ([]*entities.Comment, error)

func (*CommentRepository) Paginate

func (*CommentRepository) PaginateWithPost

func (m *CommentRepository) PaginateWithPost(ctx context.Context, filters ...*entities.CommentFilter) (*entities.Paginate[entities.Comment], error)

type FileRepository

type FileRepository struct {
	*Repository[entities.File]
}

func (*FileRepository) Count

func (m *FileRepository) Count(ctx context.Context, filters ...*entities.FileFilter) (int, error)

func (*FileRepository) Find

func (m *FileRepository) Find(ctx context.Context, filters ...*entities.FileFilter) ([]*entities.File, error)

func (*FileRepository) Paginate

func (m *FileRepository) Paginate(ctx context.Context, filters ...*entities.FileFilter) (*entities.Paginate[entities.File], error)

type Filter

type Filter struct {
	Search          string           `form:"search" json:"search"`
	Page            int              `form:"page" json:"page"`
	Limit           int              `form:"limit" json:"limit"`
	Sorts           []*entities.Sort `form:"orders" json:"orders"`
	IgnoreUrlParams []string         `form:"ignore_url_params" json:"ignore_url_params"`
	ExcludeIDs      []int            `form:"exclude_ids" json:"exclude_ids"`
}

type PermissionRepository

type PermissionRepository struct {
	*Repository[entities.Permission]
}

func (*PermissionRepository) All

func (*PermissionRepository) Count

func (m *PermissionRepository) Count(ctx context.Context, filters ...*entities.PermissionFilter) (int, error)

func (*PermissionRepository) Find

func (*PermissionRepository) Paginate

type PostRepository

type PostRepository struct {
	*Repository[entities.Post]
}

func (*PostRepository) Approve

func (m *PostRepository) Approve(ctx context.Context, id int) error

func (*PostRepository) Count

func (m *PostRepository) Count(ctx context.Context, filters ...*entities.PostFilter) (int, error)

func (*PostRepository) Find

func (m *PostRepository) Find(ctx context.Context, filters ...*entities.PostFilter) ([]*entities.Post, error)

func (*PostRepository) IncreaseViewCount

func (m *PostRepository) IncreaseViewCount(ctx context.Context, id int, views int64) error

func (*PostRepository) Paginate

func (m *PostRepository) Paginate(ctx context.Context, filters ...*entities.PostFilter) (*entities.Paginate[entities.Post], error)

func (*PostRepository) PublishedPostByID

func (m *PostRepository) PublishedPostByID(ctx context.Context, id int) (post *entities.Post, err error)

type Repository

type Repository[E entities.Entity] struct {
	Name string
	// contains filtered or unexported fields
}

func (*Repository[E]) All

func (m *Repository[E]) All(ctx context.Context) ([]*E, error)

func (*Repository[E]) ByID

func (m *Repository[E]) ByID(ctx context.Context, id int) (*E, error)

func (*Repository[E]) Create

func (m *Repository[E]) Create(ctx context.Context, entity *E) (*E, error)

func (*Repository[E]) DeleteByID

func (m *Repository[E]) DeleteByID(ctx context.Context, id int) error

func (*Repository[E]) Find

func (m *Repository[E]) Find(ctx context.Context, filters ...*Filter) ([]*E, error)

func (*Repository[E]) Paginate

func (m *Repository[E]) Paginate(ctx context.Context, filters ...*entities.Filter) (*entities.Paginate[E], error)

func (*Repository[E]) Update

func (m *Repository[E]) Update(ctx context.Context, entity *E) (*E, error)

type RoleRepository

type RoleRepository struct {
	*Repository[entities.Role]
}

func (*RoleRepository) All

func (m *RoleRepository) All(ctx context.Context) ([]*entities.Role, error)

func (*RoleRepository) ByName

func (m *RoleRepository) ByName(ctx context.Context, name string) (*entities.Role, error)

func (*RoleRepository) Count

func (m *RoleRepository) Count(ctx context.Context, filters ...*entities.RoleFilter) (int, error)

func (*RoleRepository) Find

func (m *RoleRepository) Find(ctx context.Context, filters ...*entities.RoleFilter) ([]*entities.Role, error)

func (*RoleRepository) Paginate

func (m *RoleRepository) Paginate(ctx context.Context, filters ...*entities.RoleFilter) (*entities.Paginate[entities.Role], error)

func (*RoleRepository) SetPermissions

func (m *RoleRepository) SetPermissions(ctx context.Context, id int, permissions []*entities.PermissionValue) error

type TopicRepository

type TopicRepository struct {
	*Repository[entities.Topic]
}

func (*TopicRepository) All

func (m *TopicRepository) All(ctx context.Context) ([]*entities.Topic, error)

func (*TopicRepository) ByName

func (m *TopicRepository) ByName(ctx context.Context, name string) (*entities.Topic, error)

func (*TopicRepository) Count

func (m *TopicRepository) Count(ctx context.Context, filters ...*entities.TopicFilter) (int, error)

func (*TopicRepository) Find

func (m *TopicRepository) Find(ctx context.Context, filters ...*entities.TopicFilter) ([]*entities.Topic, error)

func (*TopicRepository) Paginate

type UserRepository

type UserRepository struct {
	*Repository[entities.User]
}

func (*UserRepository) All

func (m *UserRepository) All(ctx context.Context) ([]*entities.User, error)

func (*UserRepository) ByProvider

func (m *UserRepository) ByProvider(ctx context.Context, name, id string) (*entities.User, error)

func (*UserRepository) ByUsername

func (m *UserRepository) ByUsername(ctx context.Context, name string) (*entities.User, error)

func (*UserRepository) ByUsernameOrEmail

func (m *UserRepository) ByUsernameOrEmail(ctx context.Context, username, email string) ([]*entities.User, error)

func (*UserRepository) Count

func (m *UserRepository) Count(ctx context.Context, filters ...*entities.UserFilter) (int, error)

func (*UserRepository) CreateIfNotExistsByProvider

func (m *UserRepository) CreateIfNotExistsByProvider(ctx context.Context, userData *entities.User) (*entities.User, error)

func (*UserRepository) Find

func (m *UserRepository) Find(ctx context.Context, filters ...*entities.UserFilter) ([]*entities.User, error)

func (*UserRepository) Paginate

func (m *UserRepository) Paginate(ctx context.Context, filters ...*entities.UserFilter) (*entities.Paginate[entities.User], error)

func (*UserRepository) Setting

func (m *UserRepository) Setting(ctx context.Context, id int, userData *entities.SettingMutation) (*entities.User, error)

Jump to

Keyboard shortcuts

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