group

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound  = errors.New("user not found")
	ErrInvalidID = errors.New("ID is not in its proper form")
)

Set of error variables for CRUD operations.

Functions

This section is empty.

Types

type Core

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

Core manages the set of APIs for user access.

func NewCore

func NewCore(log *zap.SugaredLogger, sqlxDB *sqlx.DB) Core

NewCore constructs a core for user api access.

func (Core) Create

func (c Core) Create(ctx context.Context, userID string, ng NewGroup, now time.Time) (Group, error)

Create inserts a new group into the database.

func (Core) Delete

func (c Core) Delete(ctx context.Context, groupID string) error

Delete removes a group from the database.

func (Core) QueryByID

func (c Core) QueryByID(ctx context.Context, groupID string) (Group, error)

QueryByID gets the specified group from the database.

func (Core) QueryWorkspaceGroups

func (c Core) QueryWorkspaceGroups(ctx context.Context, workspaceID string, pageNumber, rowsPerPage int) ([]Group, error)

QueryWorkspaceGroups retrieves a list of existing workspace from the database.

func (Core) Update

func (c Core) Update(ctx context.Context, groupID string, ug UpdateGroup, now time.Time) error

Update replaces a group document in the database.

type Group

type Group struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Wid         string    `json:"wid"`
	Uid         string    `json:"uid"`
	DateCreated time.Time `json:"date_created"`
	DateUpdated time.Time `json:"date_updated"`
}

Group represents an individual Group.

type NewGroup

type NewGroup struct {
	Name string `json:"name" validate:"required"`
	Wid  string `json:"wid"`
}

NewGroup contains information needed to create a new Group.

type UpdateGroup

type UpdateGroup struct {
	Name *string `json:"name"`
}

UpdateGroup defines what information may be provided to modify an existing group. All fields are optional so group can send just the fields they want changed. It uses pointer fields ,so we can differentiate between a field that was not provided and a field that was provided as explicitly blank. Normally we do not want to use pointers to basic types ,but we make exceptions around marshalling/unmarshalling.

Directories

Path Synopsis
Package db contains group related CRUD functionality.
Package db contains group related CRUD functionality.

Jump to

Keyboard shortcuts

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