This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
otter-space-sdk/pkg/database/database.go

69 lines
3.4 KiB
Go
Raw Normal View History

package database
2024-02-16 14:16:50 +00:00
import (
"context"
2024-02-16 20:51:09 +00:00
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
2024-02-16 14:16:50 +00:00
)
type OtterSpace interface {
// Connect establishes a connection to the database.
Connect(ctx context.Context, endpoint string, username string, password string, database string, port int, ssl string, timezone string) error
2024-02-16 14:16:50 +00:00
// AddUserWithRelationToSource adds a user with a relation to a source.
AddUserWithRelationToSource(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceDomain string, userID string, username string) error
2024-02-16 14:16:50 +00:00
// AddSource adds a new source to the database.
AddSource(ctx context.Context, anthroveSource *models.Source) error
2024-02-16 14:16:50 +00:00
// AddPost adds a new post to the database.
AddPost(ctx context.Context, anthrovePost *models.Post) error
2024-02-16 14:16:50 +00:00
// AddTagWithRelationToPost adds a tag with a relation to a post.
AddTagWithRelationToPost(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveTag *models.Tag) error
2024-02-16 14:16:50 +00:00
// LinkPostWithSource links a post with a source.
LinkPostWithSource(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveSourceDomain string, anthrovePostRelationship *models.PostReference) error
2024-02-16 14:16:50 +00:00
// LinkUserWithPost links a user with a post.
LinkUserWithPost(ctx context.Context, anthroveUser *models.User, anthrovePost *models.Post) error
2024-02-16 14:16:50 +00:00
// CheckUserPostLink checks if a user-post link exists.
CheckUserPostLink(ctx context.Context, anthroveUserID models.AnthroveUserID, sourcePostID string, sourceUrl string) (bool, error)
2024-02-16 14:16:50 +00:00
// GetPostByAnthroveID retrieves a post by its Anthrove ID.
GetPostByAnthroveID(ctx context.Context, anthrovePost *models.Post) (*models.Post, error)
2024-02-16 14:16:50 +00:00
// GetPostBySourceURL retrieves a post by its source URL.
GetPostBySourceURL(ctx context.Context, sourceUrl string) (*models.Post, error)
2024-02-16 14:16:50 +00:00
// GetPostBySourceID retrieves a post by its source ID.
GetPostBySourceID(ctx context.Context, sourcePostID string) (*models.Post, error)
2024-02-16 14:16:50 +00:00
// GetUserFavoriteCount retrieves the count of a user's favorites.
GetUserFavoriteCount(ctx context.Context, anthroveUserID models.AnthroveUserID) (int64, error)
2024-02-16 14:16:50 +00:00
// GetUserSourceLinks retrieves the source links of a user.
GetUserSourceLinks(ctx context.Context, anthroveUserID models.AnthroveUserID) (map[string]models.UserSource, error)
2024-02-16 14:16:50 +00:00
// GetSpecifiedUserSourceLink retrieves a specified source link of a user.
GetSpecifiedUserSourceLink(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceDisplayName string) (map[string]models.UserSource, error)
// GetAllAnthroveUserIDs retrieves all Anthrove user IDs.
2024-02-16 14:16:50 +00:00
GetAllAnthroveUserIDs(ctx context.Context) ([]models.AnthroveUserID, error)
// GetUserFavoritePostsWithPagination retrieves a user's favorite posts with pagination.
GetUserFavoritePostsWithPagination(ctx context.Context, anthroveUserID models.AnthroveUserID, skip int, limit int) (*models.FavoriteList, error)
// GetUserTagsTroughFavedPosts retrieves a user's tags through their favorited posts.
GetUserTagsTroughFavedPosts(ctx context.Context, anthroveUserID models.AnthroveUserID) ([]models.TagsWithFrequency, error)
2024-05-15 13:31:17 +00:00
// GetAllTags retrieves all tags.
GetAllTags(ctx context.Context) ([]models.TagsWithFrequency, error)
2024-05-15 13:44:34 +00:00
// GetAllSources retrieves all sources.
GetAllSources(ctx context.Context) ([]models.Source, error)
2024-05-21 09:48:03 +00:00
// GetSourceByURL retrieves a source by its URL.
GetSourceByURL(ctx context.Context, sourceUrl string) (*models.Source, error)
2024-02-16 14:16:50 +00:00
}