db

package
v0.0.0-...-1a8e668 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2017 License: MIT Imports: 1 Imported by: 2

Documentation

Overview

Package db contains models and DAO interfaces that packages db/postgresdb and db/mockdb will implement.

This is intended to be the primary way that the underlying application stores and fetches data.

DAO: https://en.wikipedia.org/wiki/Data_access_object

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSuchUser = errors.New("db: no such user")
)

Functions

This section is empty.

Types

type User

type User struct {
	Username      string `db:"username"`
	Email         string `db:"email"`
	PasswordHash  string `db:"password_hash"`
	IsAdmin       bool   `db:"is_admin"`
	IsDJ          bool   `db:"is_dj"`
	TwitterHandle string `db:"twitter_handle"`
}

User is a logical "user" account created for administrators or DJ's to log in and make API calls.

type UserDAOer

type UserDAOer interface {
	// Register will create a new user account with the given credentials
	// or fail with a given error.
	Register(info User, password string) (*User, error)

	// Login returns a User instance if the given username and password
	// are the same as the ones in the database.
	Login(username, password string) (ok bool, user *User, err error)

	// Info returns information about a user in the database.
	Info(username string) (*User, error)
}

UserDAOer is a common interface for all of the database calls involving user accounts (logging in, registration, etc.)

Directories

Path Synopsis
Package mockdb contains a mock database interface suitable for testing or experimentation.
Package mockdb contains a mock database interface suitable for testing or experimentation.

Jump to

Keyboard shortcuts

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