database

package
v0.0.0-...-3928e1a Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2020 License: BSD-4-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(URI string)

Connect prepares the database connection

func CreateUser

func CreateUser(user User) (int64, error)

CreateUser attempts to insert a new user to the database

func Disconnect

func Disconnect()

Disconnect the database

func SavePost

func SavePost(post Post) (int64, error)

SavePost persists a given post to database

Types

type Post

type Post struct {
	ID          int
	Title       string
	DateCreated string
}

Post is a new thread on the discussion board

func GetPosts

func GetPosts() []Post

GetPosts loads all the available posts from the database

type User

type User struct {
	ID       int64
	Username string
	Password string // Should be encrypted at all times
}

User contains everything required for a user

func GetUser

func GetUser(id int64) (User, error)

GetUser finds a user by ID (if any) and returns it

func VerifyLogin

func VerifyLogin(username string, password string) (User, error)

VerifyLogin checks if login information is correct and returns a user ID

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳