data

package
v0.0.0-...-45d6836 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDatabase

func CloseDatabase()

CloseDatabase is used to close the database connection

func CreateUser

func CreateUser(newUser model.User) error

CreateUser creates a new user

func GetLatestPosts

func GetLatestPosts(size uint) ([]model.Post, error)

GetLatestPosts for now will return all posts in the map

func GetPost

func GetPost(id int64) (model.Post, error)

GetPost retrieves a post from the database

func GetUser

func GetUser(login string) (model.User, error)

GetUser gets a user from the database

func InitializeDatabase

func InitializeDatabase(config string, log debug.Logger)

InitializeDatabase is used for strating the database connection

func NewPost

func NewPost(id int64, post model.Post) error

NewPost creates a new post

func PrintUsers

func PrintUsers()

PrintUsers is just debug for now

Types

type Access

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

Access is used for accessing the database from services

func CreateDataAccess

func CreateDataAccess() Access

CreateDataAccess returns a new data access

func (*Access) CreatePost

func (a *Access) CreatePost(post model.Post) error

CreatePost creates a new post

func (*Access) CreateUser

func (a *Access) CreateUser(newUser model.User) error

CreateUser tries to create a new user

func (*Access) GetLatestPosts

func (a *Access) GetLatestPosts(size uint) ([]model.Post, error)

GetLatestPosts for now will return posts ordered by data(probably there is a more efficient way to do this)

func (*Access) GetPost

func (a *Access) GetPost(id int64) (model.Post, error)

GetPost retrieves a post from the database

func (*Access) GetUser

func (a *Access) GetUser(login string) (model.User, error)

GetUser gets a user from the database

type AccessInterface

type AccessInterface interface {
	GetPost(id int64) (model.Post, error)
}

AccessInterface defines methods to access data

type PostAccess

type PostAccess interface {
}

PostAccess - Maybe create separated interfaces latter

Jump to

Keyboard shortcuts

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