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: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAuthNotFound = errors.New("auth not found")

ErrAuthNotFound is returned when the provided email was not found

View Source
var ErrDuplicateAuth = errors.New("auth already exists")

ErrDuplicateAuth is returned when an auth already exists

Functions

This section is empty.

Types

type Auth

type Auth struct {
	ID       uuid.UUID
	Email    string
	Password string
}

Auth encapsulates the object stored in the datastore

type BaseDatastore

type BaseDatastore interface {
	CreateAuth(input CreateAuthInput) (*Auth, error)
	ReadAuth(input ReadAuthInput) (*Auth, error)
}

BaseDatastore provides the basic datastore methods

type CreateAuthInput

type CreateAuthInput struct {
	ID       uuid.UUID
	Email    string
	Password string
}

CreateAuthInput encapsulates the information required to create a single auth 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) CreateAuth

func (dao *DAO) CreateAuth(input CreateAuthInput) (*Auth, error)

CreateAuth creates a new auth in the datastore, returning the newly created auth

func (*DAO) ReadAuth

func (dao *DAO) ReadAuth(input ReadAuthInput) (*Auth, error)

ReadAuth returns the auth in the datastore for a given email

type Datastore

type Datastore interface {
	BaseDatastore
}

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

type ReadAuthInput

type ReadAuthInput struct {
	Email string
}

ReadAuthInput encapsulates the information required to read a single auth in the datastore

Jump to

Keyboard shortcuts

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