db

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package db encapsulates all used queries to the database.

Do not forget to Initialize and Finalize.

All functions in this package might crash vividly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPost

func AddPost(post types.Post) int64

AddPost adds a new post to the database. Creation time is set by this function, ID is set by the database. The ID is returned.

func AddSession

func AddSession(token string)

func AuthorizedPosts

func AuthorizedPosts(authorized bool) (posts []types.Post)

AuthorizedPosts returns all posts stored in the database, along with their categories, but only if the viewer is authorized! Otherwise, only public posts will be given.

func AuthorizedPostsForCategory

func AuthorizedPostsForCategory(authorized bool, catName string) (posts []types.Post)

func Categories

func Categories(authorized bool) (cats []types.Category)

Categories returns all categories found on posts one has access to. They all have PostCount set to a non-zero value.

func CategoriesForPost

func CategoriesForPost(id int) (cats []types.Category)

func DeletePost

func DeletePost(id int)

func EditPost

func EditPost(post types.Post)

func Finalize

func Finalize()

Finalize closes the connection with the database.

func HasPost

func HasPost(id int) (has bool)

func HasSession

func HasSession(token string) (has bool)

func Initialize

func Initialize(filename string)

Initialize opens a SQLite3 database with the given filename. The connection is encapsulated, you cannot access the database directly, you are to use the functions provided by the package.

func LinkCount

func LinkCount() int

func MetaEntry

func MetaEntry[T any](key string) T

func NewestTime

func NewestTime() *time.Time

func OldestTime

func OldestTime() *time.Time

func PostForID

func PostForID(id int) (post types.Post, found bool)

PostForID returns the post corresponding to the given id, if there is any.

func SetCategoriesFor

func SetCategoriesFor(postID int, categories []types.Category)

func SetCredentials

func SetCredentials(name, hash string)

func StopSession

func StopSession(token string)

func URLForID

func URLForID(id int) (url sql.NullString)

URLForID returns the URL of the post corresponding to the given ID, if there is any post like that.

Types

This section is empty.

Jump to

Keyboard shortcuts

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