storage

package
v0.0.0-...-4635459 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateImage

func CreateImage(image models.Image) error

func CreatePost

func CreatePost(db *sql.DB, tag, title, contentMD, contentHTML string, published, edited *time.Time, isFavorite bool, author uuid.UUID) (*models.Post, error)

CreatePost will add a post to the supplied database with the content specified in the method call. Fields given `nil` values will be marked as `NULL` in the database.

func CreateUser

func CreateUser(db *sql.DB, firstName, lastName, email, location, catchPhrase, login, hashedPw string) (*models.User, error)

CreateUser creates a User object in the supplied database with the given information.

func DeletePost

func DeletePost(db *sql.DB, id uuid.UUID) error

func GetAllFavoritePosts

func GetAllFavoritePosts(db *sql.DB) (*[]models.PostLite, error)

GetAllFavoritePosts does the same thing as GetAllPosts, but only returns the posts marked as IsFavorite in the database.

func GetAllImages

func GetAllImages() (*[]models.Image, error)

func GetAllPosts

func GetAllPosts(db *sql.DB) (*[]models.PostLite, error)

GetAllPosts will contact the database that is passed into it and query for all posts. It will then return a slice of PostLite objects, containing only minimal identifying information about the posts, meant to be used for displaying many post titles in a list.

func GetAllUsers

func GetAllUsers(db *sql.DB) (*[]models.User, error)

GetAllUsers returns a slice containing the User models of all users in the supplied database. The Login and Hashed Password fields are ignored.

func GetImageById

func GetImageById(id string) (*models.Image, error)

func GetImagesBetweenDates

func GetImagesBetweenDates(begin time.Time, end time.Time) (*[]models.Image, error)

func GetPostById

func GetPostById(db *sql.DB, id uuid.UUID) (*models.Post, error)

GetPostById returns a post from the supplied database based on the given UUID.

func GetPostByTag

func GetPostByTag(db *sql.DB, tag string) (*models.Post, error)

GetPostByTag returns a post from the supplied database based on the given tag.

func GetUserById

func GetUserById(db *sql.DB, id uuid.UUID) (*models.User, error)

GetUserById returns a User model containing information about the given user in the supplied database. The Login and Hashed Password fields are ignored.

func GetUserByPersonalLogin

func GetUserByPersonalLogin(db *sql.DB, login string) (*models.User, error)

GetUserByPersonalLogin returns a User model containing all information for the user in the supplied database. This includes the user's Login and Hashed Password. This method is meant to be used to retrieve information for a user attempting to authenticate with the system.

func GetUserCount

func GetUserCount(db *sql.DB) (int, error)

GetUserCount returns the number of admin users which exist in the supplied database.

func Initialize

func Initialize(db *sql.DB) error

Initialize runs initialization scripts to create the tables necessary for the blog functionality. These scripts are non-destructive if data already exists.

func UpdatePost

func UpdatePost(db *sql.DB, id uuid.UUID, tag, title, contentMD, contentHTML string, published, edited *time.Time, isFavorite bool, author uuid.UUID) (*models.Post, error)

UpdatePost will update a post in the supplied database, identified by the specified UUID. It will fully replace all contents of the post, except for the id field, which will always be ignored.

Types

This section is empty.

Jump to

Keyboard shortcuts

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