db

package
v0.0.0-...-4b21e95 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2022 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DuplicateIDError

type DuplicateIDError struct {
	OriginalID string
}

DuplicateIDError is an error used to encode when duplicate IDs occur (used to provide more detailed feedback and to use the correct status code)

func NewDuplicateIDError

func NewDuplicateIDError(originalID string) *DuplicateIDError

NewDuplicateIDError constructs a new DuplicateIDError

func (*DuplicateIDError) Error

func (e *DuplicateIDError) Error() string

type EventProvider

type EventProvider interface {
	// GetSingle returns a single event
	GetSingle(ctx context.Context, eventID string) (*types.Event, error)

	// Create creates a new partial event (before it is populated)
	CreatePartial(ctx context.Context, event types.Event) error

	// pass in a partial event struct
	// ignore the following fields:
	// - creatorID
	// - guildID
	// - channelID
	// - populated
	// - voteOptions
	// - userVotes
	// If userID is not the creator ID of the event, an error is returned.
	PopulateEvent(ctx context.Context, event types.Event, userID string) error

	// Update updates an existing event
	PostVotes(ctx context.Context, userID string, votes types.UserVotes, eventID string) error

	// PutUserAvailabilityAndLocation updates the user availability and location
	PutUserAvailabilityAndLocation(ctx context.Context, userID string, availability types.UserAvailability, location types.UserLocation, eventID string) error

	// GetAllEvents returns all events in the database
	GetAllEvents(ctx context.Context) ([]*types.Event, error)

	// UpdateVoteOptions updates the vote options for times and locations
	UpdateVoteOptions(ctx context.Context, voteOptions types.VoteOption, eventID string) error
}

EventProvider provides CRUD operations for types.Event structs

type NotFoundError

type NotFoundError struct {
	ID string
}

NotFoundError is an error used to encode when an ID isn't found for GetSingle, Update, and Delete operations

func NewNotFoundError

func NewNotFoundError(id string) *NotFoundError

NewNotFoundError constructs a new NotFoundError

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type Provider

type Provider interface {
	Connect(ctx context.Context) error
	Disconnect(ctx context.Context) error

	EventProvider
}

Provider represents a database provider implementation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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