postgres

package
v0.0.0-...-88b2b22 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStorage

func NewStorage(host, port, user, password, dbName string) (*sql.DB, error)

NewStorage returns a new Postgres connection

Types

type Post

type Post struct {
	ID       uint
	Content  string
	AuthorID uint
}

Post defines the properties of a Post to be listed

type PostRepository

type PostRepository struct {
	// contains filtered or unexported fields
}

PostRepository keeps data in postgres db

func NewPostRepository

func NewPostRepository(db *sql.DB) *PostRepository

NewPostRepository return a new repo

func (*PostRepository) AddPost

func (s *PostRepository) AddPost(u adding.Post) error

AddPost saves the given Post to the repository

func (*PostRepository) DeletePost

func (s *PostRepository) DeletePost(id uint) error

func (*PostRepository) GetAllPosts

func (s *PostRepository) GetAllPosts() ([]listing.Post, error)

GetAllPosts returns all Posts from the storage

type User

type User struct {
	ID       uint
	Username string
	Password string
	RoleID   uint
}

User defines the properties of a User to be listed

type UserPolicyRepository

type UserPolicyRepository struct {
	// contains filtered or unexported fields
}

func NewUserPolicyRepository

func NewUserPolicyRepository(db *sql.DB) *UserPolicyRepository

NewUserRepository return a new repo

func (*UserPolicyRepository) IsOwnerOfPost

func (s *UserPolicyRepository) IsOwnerOfPost(userID, postID uint) bool

type UserRepository

type UserRepository struct {
	// contains filtered or unexported fields
}

UserRepository keeps data in postgres db

func NewUserRepository

func NewUserRepository(db *sql.DB) *UserRepository

NewUserRepository returns a new repo

func (*UserRepository) Login

func (s *UserRepository) Login(u login.User) (uint, error)

Login checks the given User

func (*UserRepository) Register

func (s *UserRepository) Register(u register.User) (uint, error)

Jump to

Keyboard shortcuts

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