database

package
v0.0.0-...-b5ea6c6 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2019 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindOrCreateTag

func FindOrCreateTag(db *gorm.DB, str string) (tag models.Tag, err error)

FindOrCreateTag returns a models.Tag with the given string, unless there was a database error

func InjectDatabaseMiddleware

func InjectDatabaseMiddleware(db Database) mux.MiddlewareFunc

InjectDatabaseMiddleware is a middleware helper that puts the database connection into the context

func IsRecordNotFoundError

func IsRecordNotFoundError(err error) bool

IsRecordNotFoundError is an alias for gorm's IsRecordNotFoundError

func UploadFile

func UploadFile(r io.Reader, filename, filetype string) (string, error)

UploadFile uploads the given io.Reader to the S3 compatible storage

Types

type CtxDatabaseKey

type CtxDatabaseKey struct{}

CtxDatabaseKey is a helper type for contexts

type Database

type Database struct {
	*gorm.DB
}

Database represents the database connection For now it is just a type alias for the gorm.DB, but might get additional metadata.

func NewDatabase

func NewDatabase() (Database, error)

NewDatabase returns a new database using the environment variables to figure out where to connect to

func (*Database) FindUserByEmail

func (db *Database) FindUserByEmail(email string) (user models.User, err error)

FindUserByEmail finds a single uder by email, or returns an error if none can be found

Jump to

Keyboard shortcuts

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