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 ActorByAcct(user, host string) (a *types.Actor, found bool)
- func ActorByID(actorID string) (a *types.Actor, found bool)
- func AddFollower(id string)
- func AddPendingFollowing(id string)
- func AddPost(post types.Post) int64
- func AddSession(token string)
- func CountFollowers() uint
- func CountFollowing() uint
- func CountRepostsOf(id int) int
- func DeletePost(id int)
- func DeleteRepost(postId int, repostURL string)
- func DeleteTag(tagName string)
- func DescriptionForTag(tagName string) (myco string)
- func DropJob(id int64)
- func EditPost(post types.Post)
- func Finalize()
- func GetFollowers() (actors []types.Actor)
- func GetFollowing() (actors []types.Actor)
- func HasPost(id int) (has bool)
- func InitInMemoryDB()
- func Initialize(filename string)
- func KeyPemByID(keyID string) string
- func LastPost(authorized bool) (post types.Post, found bool)
- func LoadAllJobs() (jobs []jobtype.Job)
- func MarkAsSurelyFollowing(id string)
- func MetaEntry[T any](key BetulaMetaKey) T
- func MoreTestingPosts()
- func NewestTime(authorized bool) *time.Time
- func OldestTime(authorized bool) *time.Time
- func PlanJob(job jobtype.Job) int64
- func PostCount(authorized bool) uint
- func PostForID(id int) (post types.Post, found bool)
- func Posts(authorized bool, page uint) (posts []types.Post, totalPosts uint)
- func PostsForDay(authorized bool, dayStamp string) (posts []types.Post)
- func PostsWithTag(authorized bool, tagName string, page uint) (posts []types.Post, totalPosts uint)
- func RemoveFollower(id string)
- func RenameTag(oldTagName, newTagName string)
- func RepostsOf(id int) (reposts []types.RepostInfo, err error)
- func SaveRepost(postId int, repost types.RepostInfo)
- func Search(text string, includedTags []string, excludedTags []string, authorized bool, ...) (posts []types.Post, totalPosts uint)
- func SessionExists(token string) (has bool)
- func SetCredentials(name, hash string)
- func SetMetaEntry[T any](key BetulaMetaKey, val T)
- func SetTagDescription(tagName string, description string)
- func SetTagsFor(postID int, tags []types.Tag)
- func StopFollowing(id string)
- func StopSession(token string)
- func StoreValidActor(a types.Actor)
- func SubscriptionStatus(id string) types.SubscriptionRelation
- func TagCount(authorized bool) (count uint)
- func TagExists(tagName string) (has bool)
- func Tags(authorized bool) (tags []types.Tag)
- func TagsForPost(id int) (tags []types.Tag)
- type BetulaMetaKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFollower ¶ added in v1.2.0
func AddFollower(id string)
func AddPendingFollowing ¶ added in v1.2.0
func AddPendingFollowing(id string)
func AddPost ¶
AddPost adds a new original 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 CountFollowers ¶ added in v1.2.0
func CountFollowers() uint
func CountFollowing ¶ added in v1.2.0
func CountFollowing() uint
func CountRepostsOf ¶ added in v1.1.0
func DeletePost ¶
func DeletePost(id int)
func DeleteRepost ¶ added in v1.1.0
func DescriptionForTag ¶ added in v0.8.0
func DropJob ¶ added in v1.1.0
func DropJob(id int64)
DropJob removes the job specified by id from the database. Call after the job is done.
func GetFollowers ¶ added in v1.2.0
func GetFollowing ¶ added in v1.2.0
func InitInMemoryDB ¶ added in v0.8.0
func InitInMemoryDB()
InitInMemoryDB initializes a database in :memory:. Use it instead of a real db in a file for tests.
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 KeyPemByID ¶ added in v1.2.0
func LoadAllJobs ¶ added in v1.1.0
LoadAllJobs reads all jobs in the database. Call on startup once.
func MarkAsSurelyFollowing ¶ added in v1.2.0
func MarkAsSurelyFollowing(id string)
func MetaEntry ¶
func MetaEntry[T any](key BetulaMetaKey) T
func MoreTestingPosts ¶ added in v0.8.0
func MoreTestingPosts()
func NewestTime ¶
func OldestTime ¶
func PlanJob ¶ added in v1.1.0
PlanJob puts a new job into the Jobs table and returns the id of the new job.
func Posts ¶ added in v0.8.0
Posts returns all posts stored in the database, along with their tags, but only if the viewer is authorized! Otherwise, only public posts will be given.
func PostsForDay ¶ added in v0.8.0
PostsForDay returns posts for the given dayStamp, which looks like this: 2023-03-14. The result might as well be nil, that means there are no posts for the day.
func PostsWithTag ¶ added in v0.8.0
func RemoveFollower ¶ added in v1.2.0
func RemoveFollower(id string)
func RepostsOf ¶ added in v1.1.0
func RepostsOf(id int) (reposts []types.RepostInfo, err error)
RepostsOf returns all reposts known about the specified post.
func SaveRepost ¶ added in v1.1.0
func SaveRepost(postId int, repost types.RepostInfo)
func SessionExists ¶ added in v0.8.0
func SetCredentials ¶
func SetCredentials(name, hash string)
func SetMetaEntry ¶ added in v0.7.0
func SetMetaEntry[T any](key BetulaMetaKey, val T)
func SetTagDescription ¶ added in v0.8.0
func SetTagsFor ¶ added in v0.8.0
func StopFollowing ¶ added in v1.2.0
func StopFollowing(id string)
func StopSession ¶
func StopSession(token string)
func StoreValidActor ¶ added in v1.2.0
func SubscriptionStatus ¶ added in v1.2.0
func SubscriptionStatus(id string) types.SubscriptionRelation
func Tags ¶ added in v0.8.0
Tags returns all tags found on posts one has access to. They all have PostCount set to a non-zero value.
func TagsForPost ¶ added in v0.8.0
Types ¶
type BetulaMetaKey ¶ added in v0.7.0
type BetulaMetaKey string
BetulaMetaKey is key from the BetulaMeta table.
const ( BetulaMetaAdminUsername BetulaMetaKey = "Admin username" BetulaMetaAdminPasswordHash BetulaMetaKey = "Admin password hash" BetulaMetaNetworkHost BetulaMetaKey = "Network hostname" BetulaMetaNetworkPort BetulaMetaKey = "Network port" BetulaMetaSiteTitle BetulaMetaKey = "Site title HTML" BetulaMetaSiteName BetulaMetaKey = "Site name plaintext" BetulaMetaSiteDescription BetulaMetaKey = "Site description Mycomarkup" BetulaMetaSiteURL BetulaMetaKey = "WWW URL" BetulaMetaCustomCSS BetulaMetaKey = "Custom CSS" BetulaMetaPrivateKey BetulaMetaKey = "Private key PEM" BetulaMetaEnableFederation BetulaMetaKey = "Federation enabled" )