db

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	GuildSettings() GuildSettingsDB
	LikedSongs() LikedSongsDB
	PlayHistory() PlayHistoriesDB
	Tags() TagsDB
	Voters() VotersDB
	Close() error
}

func SetupDatabase

func SetupDatabase(config DatabaseConfig) (DB, error)

type DatabaseConfig

type DatabaseConfig struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	User     string `json:"user"`
	Password string `json:"password"`
	DBName   string `json:"db_name"`
	SSLMode  string `json:"ssl_mode"`
}

type GuildSettingsDB

type GuildSettingsDB interface {
	Get(guildID snowflake.Snowflake) (GuildSetting, error)
	Set(model GuildSetting) error
	Delete(guildID snowflake.Snowflake) error
}

type LikedSongsDB

type LikedSongsDB interface {
	Get(userID snowflake.Snowflake, title string) (LikedSong, error)
	GetAll(userID snowflake.Snowflake) ([]LikedSong, error)
	Add(userID snowflake.Snowflake, query string, title string) error
	Delete(userID snowflake.Snowflake, title string) error
	DeleteAll(userID snowflake.Snowflake) error
}

type PlayHistoriesDB

type PlayHistoriesDB interface {
	Get(userID snowflake.Snowflake) ([]PlayHistory, error)
	Add(userID snowflake.Snowflake, query string, title string) error
}

type TagsDB

type TagsDB interface {
	Get(guildID snowflake.Snowflake, name string) (Tag, error)
	GetAll(guildID snowflake.Snowflake) ([]Tag, error)
	Create(guildID snowflake.Snowflake, ownerID snowflake.Snowflake, name string, content string) error
	Edit(guildID snowflake.Snowflake, name string, content string) error
	IncrementUses(guildID snowflake.Snowflake, name string) error
	Delete(guildID snowflake.Snowflake, name string) error
}

type VotersDB

type VotersDB interface {
	GetAll(expiresAt time.Time) ([]Voter, error)
	Add(userID snowflake.Snowflake, duration time.Duration) error
	Delete(userID snowflake.Snowflake) error
}

Jump to

Keyboard shortcuts

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