database

package
v0.0.0-...-248acc2 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvPostgresURI      = "postgres.address"
	EnvPostgresDatabase = "postgres.database"
	EnvPostgresUser     = "postgres.user"
	EnvPostgresPassword = "postgres.password"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DiscordChannel

type DiscordChannel struct {
	ID         int
	ExternalID string
}

type DiscordServer

type DiscordServer struct {
	ID         int
	ExternalID string
}

type Notification

type Notification struct {
	ID        int
	PostID    int
	ChannelID int
	RuleID    int
}

type PGXStore

type PGXStore struct {
	*pgxpool.Pool
}

func New

func New(ctx ctx.Ctx) (*PGXStore, error)

func (*PGXStore) GetDiscordChannel

func (db *PGXStore) GetDiscordChannel(ctx context.Context, channelID int) (*DiscordChannel, error)

func (*PGXStore) GetDiscordChannelByExternalID

func (db *PGXStore) GetDiscordChannelByExternalID(ctx context.Context, channelID string) (*DiscordChannel, error)

func (*PGXStore) GetDiscordServerByExternalID

func (db *PGXStore) GetDiscordServerByExternalID(ctx context.Context, serverID string) (*DiscordServer, error)

func (*PGXStore) GetNotification

func (db *PGXStore) GetNotification(ctx context.Context, postID, channelID, ruleID int) (*Notification, error)

func (*PGXStore) GetNotificationCount

func (db *PGXStore) GetNotificationCount(ctx context.Context, postID, channelID, ruleID int) (int, error)

func (*PGXStore) GetPostByExternalID

func (db *PGXStore) GetPostByExternalID(ctx context.Context, postID string) (*Post, error)

func (*PGXStore) GetRules

func (db *PGXStore) GetRules(ctx context.Context, subreddit int) ([]*Rule, error)

func (*PGXStore) GetSubredditByExternalID

func (db *PGXStore) GetSubredditByExternalID(ctx context.Context, subredditID string) (*Subreddit, error)

func (*PGXStore) GetSubreddits

func (db *PGXStore) GetSubreddits(ctx context.Context) ([]*Subreddit, error)

func (*PGXStore) InsertDiscordChannel

func (db *PGXStore) InsertDiscordChannel(ctx context.Context, channelID string, serverID int) (*DiscordChannel, error)

func (*PGXStore) InsertDiscordServer

func (db *PGXStore) InsertDiscordServer(ctx context.Context, serverID string) (*DiscordServer, error)

func (*PGXStore) InsertNotification

func (db *PGXStore) InsertNotification(ctx context.Context, postID, channelID, ruleID int) (*Notification, error)

func (*PGXStore) InsertPost

func (db *PGXStore) InsertPost(ctx context.Context, postID string) (*Post, error)

func (*PGXStore) InsertRule

func (db *PGXStore) InsertRule(ctx context.Context, rule Rule) (*Rule, error)

func (*PGXStore) InsertSubreddit

func (db *PGXStore) InsertSubreddit(ctx context.Context, subredditID string) (*Subreddit, error)

type Post

type Post struct {
	ID         int
	ExternalID string
}

type Rule

type Rule struct {
	ID               int
	Target           string
	Exact            bool
	TargetId         string
	DiscordServerID  int
	SubredditID      int
	DiscordChannelID int
}

type Store

type Store interface {
	InsertDiscordServer(ctx context.Context, serverID string) (*DiscordServer, error)
	InsertDiscordChannel(ctx context.Context, channelID string, serverID int) (*DiscordChannel, error)
	InsertNotification(ctx context.Context, postID, channelID, ruleID int) (*Notification, error)
	InsertSubreddit(ctx context.Context, subredditID string) (*Subreddit, error)
	InsertRule(ctx context.Context, rule Rule) (*Rule, error)
	InsertPost(ctx context.Context, postID string) (*Post, error)

	GetDiscordServerByExternalID(ctx context.Context, serverID string) (*DiscordServer, error)
	GetSubredditByExternalID(ctx context.Context, subreddit string) (*Subreddit, error)

	GetDiscordChannel(ctx context.Context, channelID int) (*DiscordChannel, error)
	GetRules(ctx context.Context, subreddit int) ([]*Rule, error)
	GetSubreddits(ctx context.Context) ([]*Subreddit, error)
	GetNotificationCount(ctx context.Context, postID, channelID, ruleID int) (int, error)
}

type Subreddit

type Subreddit struct {
	ID         int
	ExternalID string
}

Jump to

Keyboard shortcuts

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