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 ¶
- func AddPost(post types.Post) int64
- func AddSession(token string)
- func AuthorizedPosts(authorized bool) (posts []types.Post)
- func AuthorizedPostsForCategory(authorized bool, catName string) (posts []types.Post)
- func Categories(authorized bool) (cats []types.Category)
- func CategoriesForPost(id int) (cats []types.Category)
- func DeletePost(id int)
- func EditPost(post types.Post)
- func Finalize()
- func HasPost(id int) (has bool)
- func HasSession(token string) (has bool)
- func Initialize(filename string)
- func LinkCount() int
- func MetaEntry[T any](key string) T
- func NewestTime() *time.Time
- func OldestTime() *time.Time
- func PostForID(id int) (post types.Post, found bool)
- func SetCategoriesFor(postID int, categories []types.Category)
- func SetCredentials(name, hash string)
- func StopSession(token string)
- func URLForID(id int) (url sql.NullString)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddPost ¶
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 ¶
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 Categories ¶
Categories returns all categories found on posts one has access to. They all have PostCount set to a non-zero value.
func CategoriesForPost ¶
func DeletePost ¶
func DeletePost(id int)
func HasSession ¶
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 NewestTime ¶
func OldestTime ¶
func SetCategoriesFor ¶
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.