database

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

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

Go to latest
Published: Nov 22, 2019 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GET_ALL_POSTS = "" /* 142-byte string literal not displayed */
	ADD_POST      = "INSERT INTO posts VALUES(DEFAULT, $1, $2, $3, $4);"
)
View Source
const DATABASE_SETTINGS_FILE = "database_settings.json"

DATABASE_SETTINGS_FILE is the file that will be read to make a postgres url

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseConnection

type DatabaseConnection struct {
	Username     string `json:"username"`
	Password     string `json:"password"`
	Port         string `json:"port"`
	DatabaseName string `json:"databaseName"`
	// contains filtered or unexported fields
}

DatabaseConnection holds all the important data for the postgres connection

func CreateDatabaseConnection

func CreateDatabaseConnection() DatabaseConnection

Creates the DatabaseConnection object

func (*DatabaseConnection) AddPost

func (dbConn *DatabaseConnection) AddPost(post Post) error

func (DatabaseConnection) CheckIfUserExists

func (dbConn DatabaseConnection) CheckIfUserExists(username string) bool

checks if a user exists

func (DatabaseConnection) CreateUser

func (dbConn DatabaseConnection) CreateUser(username, password string)

checks if a user exists

func (*DatabaseConnection) GetAllPosts

func (dbConn *DatabaseConnection) GetAllPosts() Posts

func (DatabaseConnection) GetIdFromUsername

func (dbConn DatabaseConnection) GetIdFromUsername(username string) int64

GetUsername gets the users password from the id

func (DatabaseConnection) GetPasswordById

func (dbConn DatabaseConnection) GetPasswordById(id int64) (string, error)

GetUsername gets the users password from the id

func (DatabaseConnection) GetPasswordByUsername

func (dbConn DatabaseConnection) GetPasswordByUsername(username string) (string, error)

GetUsername gets the users password from the id

func (DatabaseConnection) GetUsername

func (dbConn DatabaseConnection) GetUsername(id int64) (string, error)

GetUsername gets the users username from the id

func (DatabaseConnection) VerifyPasswordByUsername

func (dbConn DatabaseConnection) VerifyPasswordByUsername(username, password string) bool

Verifys the password of a user

type Post

type Post struct {
	Id        int64     `json:"id"`
	Username  string    `json:"username"`
	Mood      string    `json:"mood"`
	Genre     string    `json:"genre"`
	Post      string    `json:"post"`
	Timestamp time.Time `json:"timestamp"`
}

type Posts

type Posts struct {
	Posts []Post `json:"posts"`
}

type User

type User struct {
	Id       int64
	Username string
	Password string
}

Jump to

Keyboard shortcuts

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