area

package
v42.0.0-...-56f38d9 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package area provides all the required functions to manage the definition of areas.

Index

Constants

View Source
const APIStringTypeAreas = "areas"

Variables

This section is empty.

Functions

func FilterByName

func FilterByName(name string) func(db *gorm.DB) *gorm.DB

FilterByName is a gorm filter by 'name'

func FilterByPath

func FilterByPath(pathOfParent path.Path) func(db *gorm.DB) *gorm.DB

FilterByPath is a gorm filter by 'path' of the parent area for any given area.

func FilterBySpaceID

func FilterBySpaceID(spaceID uuid.UUID) func(db *gorm.DB) *gorm.DB

FilterBySpaceID is a gorm filter for a Belongs To relationship.

Types

type Area

type Area struct {
	gormsupport.Lifecycle
	ID      uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key"` // This is the ID PK field
	SpaceID uuid.UUID `sql:"type:uuid"`
	Path    path.Path
	Name    string
	Version int
}

Area describes a single Area

func (Area) GetETagData

func (m Area) GetETagData() []interface{}

GetETagData returns the field values to use to generate the ETag

func (Area) GetLastModified

func (m Area) GetLastModified() time.Time

GetLastModified returns the last modification time

func (Area) TableName

func (m Area) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type GormAreaRepository

type GormAreaRepository struct {
	// contains filtered or unexported fields
}

GormAreaRepository is the implementation of the storage interface for Areas.

func (*GormAreaRepository) CheckExists

func (m *GormAreaRepository) CheckExists(ctx context.Context, id string) error

CheckExists returns nil if the given ID exists otherwise returns an error

func (*GormAreaRepository) Create

func (m *GormAreaRepository) Create(ctx context.Context, u *Area) error

Create creates a new record.

func (*GormAreaRepository) List

func (m *GormAreaRepository) List(ctx context.Context, spaceID uuid.UUID) ([]Area, error)

List all Areas related to a single item

func (*GormAreaRepository) ListChildren

func (m *GormAreaRepository) ListChildren(ctx context.Context, parentArea *Area) ([]Area, error)

ListChildren fetches all Areas belonging to a parent - list all child areas.

func (*GormAreaRepository) Load

func (m *GormAreaRepository) Load(ctx context.Context, id uuid.UUID) (*Area, error)

Load a single Area regardless of parent

func (*GormAreaRepository) LoadMultiple

func (m *GormAreaRepository) LoadMultiple(ctx context.Context, ids []uuid.UUID) ([]Area, error)

Load multiple areas

func (*GormAreaRepository) Query

func (m *GormAreaRepository) Query(funcs ...func(*gorm.DB) *gorm.DB) ([]Area, error)

Query exposes an open ended Query model for Area

func (*GormAreaRepository) Root

func (m *GormAreaRepository) Root(ctx context.Context, spaceID uuid.UUID) (*Area, error)

Root fetches the Root Areas inside a space.

type Repository

type Repository interface {
	repository.Exister
	Create(ctx context.Context, u *Area) error
	List(ctx context.Context, spaceID uuid.UUID) ([]Area, error)
	Load(ctx context.Context, id uuid.UUID) (*Area, error)
	LoadMultiple(ctx context.Context, ids []uuid.UUID) ([]Area, error)
	ListChildren(ctx context.Context, parentArea *Area) ([]Area, error)
	Query(funcs ...func(*gorm.DB) *gorm.DB) ([]Area, error)
	Root(ctx context.Context, spaceID uuid.UUID) (*Area, error)
}

Repository describes interactions with Areas

func NewAreaRepository

func NewAreaRepository(db *gorm.DB) Repository

NewAreaRepository creates a new storage type.

Jump to

Keyboard shortcuts

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