db

package
v0.0.0-...-dbd7530 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeRandom

func MakeRandom() model.UserInfo

Types

type Bot

type Bot struct {
	ID        string `gorm:"primaryKey"`
	GuildID   string `gorm:"primaryKey"`
	Wav       string
	CreatedAt time.Time
	UpdatedAt time.Time
}

type Database

type Database struct {
	DBName string
	DB     *gorm.DB
}

func NewDatabase

func NewDatabase(dbName string) *Database

func (*Database) AddBot

func (c *Database) AddBot(guildID, botID string, wavList []string) error

func (*Database) AddUser

func (c *Database) AddUser(userID string, userInfo model.UserInfo) error

func (*Database) AddWord

func (c *Database) AddWord(guildID, pre, post string) error

func (*Database) BulkAddUser

func (c *Database) BulkAddUser(userList []User) error

func (*Database) Connect

func (c *Database) Connect() error

func (*Database) CreateGuild

func (c *Database) CreateGuild(guildID string) error

func (*Database) DeleteBot

func (c *Database) DeleteBot(guildID, botID string) error

func (*Database) DeleteWord

func (c *Database) DeleteWord(guildID, key string) error

func (*Database) GetUser

func (c *Database) GetUser(userID string) (User, error)

func (*Database) ListBots

func (c *Database) ListBots(guildID string) (map[string][]string, error)

func (*Database) ListGuilds

func (c *Database) ListGuilds() ([]Guild, error)

func (*Database) ListWords

func (c *Database) ListWords(guildID string) (map[string]string, error)

func (*Database) Migrate

func (c *Database) Migrate() error

func (*Database) NewUser

func (c *Database) NewUser(userID string) (User, error)

type Guild

type Guild struct {
	ID        string `gorm:"primaryKey"`
	Bots      []Bot
	Words     []Word
	CreatedAt time.Time
	UpdatedAt time.Time
}

type User

type User struct {
	ID        string         `gorm:"primaryKey"`
	UserInfo  model.UserInfo `gorm:"embedded"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

type Word

type Word struct {
	GuildID   string `gorm:"primaryKey"`
	Before    string `gorm:"primaryKey"`
	After     string
	CreatedAt time.Time
	UpdatedAt time.Time
}

Jump to

Keyboard shortcuts

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