dao

package
v0.0.0-...-82d3620 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseDatastore

type BaseDatastore interface {
	CreateUser(input CreateUserInput) (*User, error)
	ReadUser(input ReadUserInput) (*User, error)
	UpdateUser(input UpdateUserInput) (*User, error)
	DeleteUser(input DeleteUserInput) error
	CreatePicture(input CreatePictureInput) (*Picture, error)
	ReadPicture(input ReadPictureInput) (*Picture, error)
	UpdatePicture(input UpdatePictureInput) (*Picture, error)
	DeletePicture(input DeletePictureInput) error
}

BaseDatastore provides the basic datastore methods

type CreatePictureInput

type CreatePictureInput struct {
	ID     uuid.UUID
	UserID uuid.UUID
	Img    []byte
}

CreatePictureInput enapsulates the information required to create a single picture in the datastore

type CreateUserInput

type CreateUserInput struct {
	ID   uuid.UUID
	Name string
}

CreateUserInput encapsulates the information required to create a single user in the datastore

type DAO

type DAO struct {
	DB *sql.DB
}

DAO encapsulates access to the datastore

func Init

func Init(config *util.Config) (*DAO, error)

Init opens the datastore connection, returning a DAO

func (*DAO) CreatePicture

func (dao *DAO) CreatePicture(input CreatePictureInput) (*Picture, error)

CreatePicture new picture in the datastore, returning the newly created picture

func (*DAO) CreateUser

func (dao *DAO) CreateUser(input CreateUserInput) (*User, error)

CreateUser creates a new user in the datastore, returning the newly created user

func (*DAO) DeletePicture

func (dao *DAO) DeletePicture(input DeletePictureInput) error

DeletePicture deletes a single picture from the datastore

func (*DAO) DeleteUser

func (dao *DAO) DeleteUser(input DeleteUserInput) error

DeleteUser deletes a user in the datastore

func (*DAO) ReadPicture

func (dao *DAO) ReadPicture(input ReadPictureInput) (*Picture, error)

ReadPicture returns the picture in the datastore for a given ID

func (*DAO) ReadUser

func (dao *DAO) ReadUser(input ReadUserInput) (*User, error)

ReadUser returns the user in the datastore for a given ID

func (*DAO) UpdatePicture

func (dao *DAO) UpdatePicture(input UpdatePictureInput) (*Picture, error)

UpdatePicture updates a picture in the datastore, returning an error if it fails

func (*DAO) UpdateUser

func (dao *DAO) UpdateUser(input UpdateUserInput) (*User, error)

UpdateUser updates a user in the datastore, returning an error if it fails

type Datastore

type Datastore interface {
	BaseDatastore
}

Datastore provides the interface adopted by the DAO, allowing for mocking

type DeletePictureInput

type DeletePictureInput struct {
	ID     uuid.UUID
	UserID uuid.UUID
}

DeletePictureInput encapsulates the information required to delete a single picture in the datastore

type DeleteUserInput

type DeleteUserInput struct {
	ID uuid.UUID
}

DeleteUserInput encapsulates the information required to delete a single user in the datastore

type ErrPictureNotFound

type ErrPictureNotFound string

ErrPictureNotFound is returned when a picture for the provided ID was not found

func (ErrPictureNotFound) Error

func (e ErrPictureNotFound) Error() string

type ErrUserNotFound

type ErrUserNotFound string

ErrUserNotFound is returned when a user for the provided ID was not found

func (ErrUserNotFound) Error

func (e ErrUserNotFound) Error() string

type Picture

type Picture struct {
	ID     uuid.UUID
	UserID uuid.UUID
	Img    []byte
}

Picture encapsulates the object stored in the datastore

type ReadPictureInput

type ReadPictureInput struct {
	ID     uuid.UUID
	UserID uuid.UUID
}

ReadPictureInput enapsulates the information required to read a single picture in the datastore

type ReadUserInput

type ReadUserInput struct {
	ID uuid.UUID
}

ReadUserInput encapsulates the information required to read a single user in the datastore

type UpdatePictureInput

type UpdatePictureInput struct {
	ID     uuid.UUID
	UserID uuid.UUID
	Img    []byte
}

UpdatePictureInput enapsulates the information required to update a single picture in the datastore

type UpdateUserInput

type UpdateUserInput struct {
	ID   uuid.UUID
	Name string
}

UpdateUserInput encapsulates the information required to update a single user in the datastore

type User

type User struct {
	ID   uuid.UUID
	Name string
}

User encapsulates the object stored in the datastore

Jump to

Keyboard shortcuts

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