post05

package module
v0.0.0-...-e784451 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

README

post05

Working with PostgreSQL DB in Go

Create tables by running the next command:

$ psql -h localhost -p 5432 -U mtsouk master < create_tables.sql

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Hostname = ""
	Port     = 2345
	Username = ""
	Password = ""
	Database = ""
)

Connection details

Functions

func AddUser

func AddUser(d Userdata) int

AddUser adds a new user to the database Returns new User ID -1 if there was an error

func DeleteUser

func DeleteUser(id int) error

DeleteUser deletes an existing user

func UpdateUser

func UpdateUser(d Userdata) error

UpdateUser is for updating an existing user

Types

type Userdata

type Userdata struct {
	ID          int
	Username    string
	Name        string
	Surname     string
	Description string
}

Userdata is for holding full user data Userdata table + Username

func ListUsers

func ListUsers() ([]Userdata, error)

ListUsers lists all users in the database

Jump to

Keyboard shortcuts

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