db

package
v0.0.0-...-2f70b81 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Database *pg.DB

Functions

func ConnectDB

func ConnectDB()

func CreateSchema

func CreateSchema(db *pg.DB) error

func DeleteThreadById

func DeleteThreadById(id int64) error

func DeleteUserById

func DeleteUserById(id int64) error

func GetAll

func GetAll(model *ListableModel) error

func Migrate

func Migrate() error

func WrapDBQueryError

func WrapDBQueryError(err error) error

Types

type AuthenticationError

type AuthenticationError struct {
	Username string
	Id       int64
	Message  string
}

Used for when the user was unable to be authenticated.

func (*AuthenticationError) Error

func (e *AuthenticationError) Error() string

type GettableModel

type GettableModel interface {
	GetById() *GettableModel
}
type Link struct {
	Id     int64
	URL    string
	Poster *User
}
func CreateLink(url string, poster *User) (*Link, error)

func (Link) String

func (l Link) String() string

type ListableModel

type ListableModel interface {
	GetAllModels() []*ListableModel
	GetAllByFilter() []*ListableModel
}

type PermissionsError

type PermissionsError struct {
	Username string
	Id       int64
	Message  string
}

Used for when the user doesn't have the correct permissions to perform an action.

func (*PermissionsError) Error

func (e *PermissionsError) Error() string

type Thread

type Thread struct {
	Id    int64
	Users []*User
	Title string `sql:",unique"`
	Links []*Link
}

func CreateThread

func CreateThread(threadTitle string, creator *User) (*Thread, error)

func GetAllThreads

func GetAllThreads() ([]Thread, error)

func GetThreadById

func GetThreadById(threadId int64) (*Thread, error)

func GetThreadByTitle

func GetThreadByTitle(threadTitle string) (*Thread, error)
func (t Thread) AddLink(link *Link) error

func (Thread) AddUser

func (t Thread) AddUser(user *User) error
func (t Thread) RemoveLink(link *Link) error

func (Thread) RemoveUser

func (t Thread) RemoveUser(user *User) error

func (Thread) String

func (t Thread) String() string

func (Thread) UpdateModel

func (t Thread) UpdateModel() error

func (Thread) UpdateTitle

func (t Thread) UpdateTitle(title string) error

func (Thread) UserIsSubscribed

func (t Thread) UserIsSubscribed(user User) bool

type User

type User struct {
	Id    int64
	Name  string `sql:",unique"`
	Email string `sql:",unique"`
}

func CreateUser

func CreateUser(name string, email string) (*User, error)

func GetAllUsers

func GetAllUsers() ([]User, error)

func GetUserByEmail

func GetUserByEmail(email string) (*User, error)

func GetUserById

func GetUserById(id int64) (*User, error)

func GetUserByUsername

func GetUserByUsername(username string) (*User, error)

func (User) String

func (u User) String() string

func (User) UpdateEmail

func (u User) UpdateEmail(email string) error

func (User) UpdateName

func (u User) UpdateName(name string) error

Jump to

Keyboard shortcuts

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