repo

package
v0.0.0-...-11c8b56 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2018 License: AGPL-3.0 Imports: 8 Imported by: 12

Documentation

Overview

Package repo provides definitions for abstracting away database interaction in Praelatus

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLoginRequired          error = errors.New("you must be logged in")
	ErrAdminRequired                = errors.New("you must be an administrator")
	ErrUnauthorized                 = errors.New("permission denied")
	ErrNotFound                     = errors.New("not found")
	ErrInvalidTicketType            = errors.New("invalid ticket type for project")
	ErrInvalidFieldsForTicket       = errors.New("invalid fields for ticket of that type for project")
)

Errors

Functions

func Clean

func Clean() error

Clean is an alias to the method of the same name on the global Repo

func Init

func Init() error

Init is an alias to the method of the same name on the global Repo

func Seed

func Seed(r Repo) error

Seed will fill the given repo with test data.

func Test

func Test() error

Test is an alias to the method of the same name on the global Repo

Types

type Cache

type Cache interface {
	Get(key string) (interface{}, error)
	Set(key string, value interface{}) error
	Remove(key string) error
	GetSession(key string) (models.Session, error)
	SetSession(key string, user models.Session) error
	RemoveSession(key string) error
}

Cache is used for storing temporary resources. Usually backed by Mongo, Bolt or Redis

type FieldSchemeRepo

type FieldSchemeRepo interface {
	Get(u *models.User, uid string) (models.FieldScheme, error)
	Search(u *models.User, query string) ([]models.FieldScheme, error)
	Update(u *models.User, uid string, updated models.FieldScheme) error
	Create(u *models.User, fieldScheme models.FieldScheme) (models.FieldScheme, error)
	Delete(u *models.User, uid string) error
}

FieldSchemeRepo handles storing, retrieving, updating, and creating field schemes.

func Fields

func Fields() FieldSchemeRepo

Fields is an alias to the method of the same name on the global Repo

type NotificationRepo

type NotificationRepo interface {
	Create(u *models.User, notification models.Notification) (models.Notification, error)

	MarkRead(u *models.User, uid string) error

	ForProject(u *models.User, project models.Project, onlyUnread bool, last int) ([]models.Notification, error)
	ForUser(u *models.User, user models.User, onlyUnread bool, last int) ([]models.Notification, error)
	ActivityForUser(u *models.User, user models.User, onlyUnread bool, last int) ([]models.Notification, error)
}

NotificationRepo handles storing, retrieving, updating, and creating workflows.

func Notifications

func Notifications() NotificationRepo

Notifications is an alias to the method of the same name on the global Repo

type ProjectRepo

type ProjectRepo interface {
	Get(u *models.User, uid string) (models.Project, error)
	Search(u *models.User, query string) ([]models.Project, error)
	Update(u *models.User, uid string, updated models.Project) error
	Create(u *models.User, project models.Project) (models.Project, error)
	Delete(u *models.User, uid string) error

	HasLead(u *models.User, lead models.User) ([]models.Project, error)
	HasPermissionTo(u *models.User, perms permission.Permissions) ([]models.Project, error)
}

ProjectRepo handles storing, retrieving, updating, and creating projects.

func Projects

func Projects() ProjectRepo

Projects is an alias to the method of the same name on the global Repo

type Repo

type Repo interface {
	Tickets() TicketRepo
	Projects() ProjectRepo
	Users() UserRepo
	Fields() FieldSchemeRepo
	Workflows() WorkflowRepo
	Notifications() NotificationRepo

	Clean() error
	Test() error
	Init() error
}

Repo is a container interface for combining all the other repos.

var GlobalRepo Repo

GlobalRepo is used to store a global repo instance that can be accessed from anywhere in the application

func NewMockRepo

func NewMockRepo() Repo

type TicketRepo

type TicketRepo interface {
	Get(u *models.User, uid string) (models.Ticket, error)
	Search(u *models.User, query ast.AST) ([]models.Ticket, error)
	Update(u *models.User, uid string, updated models.Ticket) error
	Create(u *models.User, ticket models.Ticket) (models.Ticket, error)
	Delete(u *models.User, uid string) error

	AddComment(u *models.User, uid string, comment models.Comment) (models.Ticket, error)
	NextTicketKey(u *models.User, projectKey string) (string, error)
	LabelSearch(u *models.User, query string) ([]string, error)
}

TicketRepo handles storing, retrieving, updating, and creating tickets.

func Tickets

func Tickets() TicketRepo

Tickets is an alias to the method of the same name on the global Repo

type UserRepo

type UserRepo interface {
	Get(u *models.User, uid string) (models.User, error)
	Search(u *models.User, query string) ([]models.User, error)
	Update(u *models.User, uid string, updated models.User) error
	Create(u *models.User, user models.User) (models.User, error)
	Delete(u *models.User, uid string) error
}

UserRepo handles storing, retrieving, updating, and creating users.

func Users

func Users() UserRepo

Users is an alias to the method of the same name on the global Repo

type WorkflowRepo

type WorkflowRepo interface {
	Get(u *models.User, uid string) (models.Workflow, error)
	Search(u *models.User, query string) ([]models.Workflow, error)
	Update(u *models.User, uid string, updated models.Workflow) error
	Create(u *models.User, workflow models.Workflow) (models.Workflow, error)
	Delete(u *models.User, uid string) error
}

WorkflowRepo handles storing, retrieving, updating, and creating workflows.

func Workflows

func Workflows() WorkflowRepo

Workflows is an alias to the method of the same name on the global Repo

Directories

Path Synopsis
Package mongo implements repo.Repo for a mongodb database.
Package mongo implements repo.Repo for a mongodb database.

Jump to

Keyboard shortcuts

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