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 AddSession(token, userAgent string)
- func BookmarkCount(authorized bool) uint
- func Bookmarks(authorized bool, page uint) (bookmarks []types.Bookmark, total uint)
- func BookmarksForDay(authorized bool, dayStamp string) (bookmarks []types.Bookmark)
- func BookmarksWithTag(authorized bool, tagName string, page uint) (bookmarks []types.Bookmark, total uint)
- func CountFollowers() uint
- func CountFollowing() uint
- func CountRepostsOf(id int) int
- func DeleteBookmark(id int)
- func DeleteRemoteBookmark(bid string)
- func DeleteRepost(bookmarkID int, repostURL string)
- func DeleteTag(tagName string)
- func DescriptionForTag(tagName string) (myco string)
- func DropJob(id int64)
- func EditBookmark(bookmark types.Bookmark)
- func Finalize()
- func GetBookmarkByID(id int) (b types.Bookmark, found bool)
- func GetFollowers() (actors []types.Actor)
- func GetFollowing() (actors []types.Actor)
- func GetRemoteBookmarks(page uint) (bookmarks []types.RemoteBookmark, total uint)
- func GetRemoteBookmarksBy(authorID string, page uint) (bookmarks []types.RemoteBookmark, total uint)
- func InitInMemoryDB()
- func Initialize(filename string)
- func InsertBookmark(bookmark types.Bookmark) int64
- func InsertRemoteBookmark(b types.RemoteBookmark)
- func KeyPemByID(keyID string) string
- func LoadAllJobs() (jobs []jobtype.Job)
- func MarkAsSurelyFollowing(id string)
- func MetaEntry[T any](key BetulaMetaKey) T
- func MoreTestingBookmarks()
- func NewestTime(authorized bool) *time.Time
- func OldestTime(authorized bool) *time.Time
- func PlanJob(job jobtype.Job) int64
- func RandomBookmarks(authorized bool, n uint) (bookmarks []types.Bookmark, total uint)
- func RemoteBookmarkIsStored(bid string) (isStored bool)
- func RemoveFollower(id string)
- func RenameTag(oldTagName, newTagName string)
- func RepostsOf(id int) (reposts []types.RepostInfo, err error)
- func SaveRepost(bookmarkID int, repost types.RepostInfo)
- func Search(text string, includedTags []string, excludedTags []string, ...) (results []types.Bookmark, totalResults uint)
- func SessionExists(token string) (has bool)
- func Sessions() (sessions []types.Session)
- func SetCredentials(name, hash string)
- func SetMetaEntry[T any](key BetulaMetaKey, val T)
- func SetTagDescription(tagName string, description string)
- func SetTagsFor(bookmarkID int, tags []types.Tag)
- func StopAllSessions(excludeToken string)
- 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 TagsForBookmarkByID(id int) (tags []types.Tag)
- func UpdateRemoteBookmark(b types.RemoteBookmark)
- 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 AddSession ¶
func AddSession(token, userAgent string)
func BookmarkCount ¶ added in v1.3.0
func Bookmarks ¶ added in v1.3.0
Bookmarks returns all bookmarks stored in the database on the given page, along with their tags, but only if the viewer is authorized! Otherwise, only public bookmarks will be given.
func BookmarksForDay ¶ added in v1.3.0
BookmarksForDay returns bookmarks for the given dayStamp, which looks like this: 2023-03-14. The result might as well be nil, that means there are no bookmarks for the day.
func BookmarksWithTag ¶ added in v1.3.0
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 DeleteBookmark ¶ added in v1.3.0
func DeleteBookmark(id int)
func DeleteRemoteBookmark ¶ added in v1.3.0
func DeleteRemoteBookmark(bid string)
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 EditBookmark ¶ added in v1.3.0
func GetBookmarkByID ¶ added in v1.3.0
GetBookmarkByID returns the bookmark corresponding to the given id, if there is any.
func GetFollowers ¶ added in v1.2.0
func GetFollowing ¶ added in v1.2.0
func GetRemoteBookmarks ¶ added in v1.3.0
func GetRemoteBookmarks(page uint) (bookmarks []types.RemoteBookmark, total uint)
func GetRemoteBookmarksBy ¶ added in v1.3.0
func GetRemoteBookmarksBy(authorID string, page uint) (bookmarks []types.RemoteBookmark, total uint)
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 InsertBookmark ¶ added in v1.3.0
InsertBookmark adds a new local bookmark to the database. Creation time is set by this function, ID is set by the database. The ID is returned.
func InsertRemoteBookmark ¶ added in v1.3.0
func InsertRemoteBookmark(b types.RemoteBookmark)
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 MoreTestingBookmarks ¶ added in v1.3.0
func MoreTestingBookmarks()
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 RandomBookmarks ¶ added in v1.3.0
func RemoteBookmarkIsStored ¶ added in v1.3.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 bookmark.
func SaveRepost ¶ added in v1.1.0
func SaveRepost(bookmarkID 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 StopAllSessions ¶ added in v1.3.0
func StopAllSessions(excludeToken string)
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 bookmarks one has access to. They all have BookmarkCount set to a non-zero value.
func TagsForBookmarkByID ¶ added in v1.3.0
func UpdateRemoteBookmark ¶ added in v1.3.0
func UpdateRemoteBookmark(b types.RemoteBookmark)
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" )