Documentation ¶
Index ¶
- Constants
- func CloseDB() error
- func ConnectToDB(dbType DBType, databaseURI string) error
- func DeleteGame(game Game) error
- func DeleteMessage(message Message) error
- func DeleteUser(user User) error
- func InsertGame(game Game) error
- func InsertGameUserAssoc(game Game, user User) error
- func InsertMessage(message Message) error
- func InsertUser(user User) error
- func InsertUserMessageAssoc(message Message, user User) error
- func IsInGameDB(game Game) (bool, error)
- func IsInMsgDB(msg Message) (bool, error)
- func IsInUserDB(user User) (bool, error)
- func UpdateGame(game Game) error
- func UpdateMessage(message Message) error
- func UpdateUser(user User) error
- type DBType
- type Game
- type Message
- type User
- type UserRole
Constants ¶
const ( INACTIVE = 0 UNREGISTERED = 1 REGISTERED = 2 MEMBER = 3 OFFICER = 4 // OP ADMIN = 5 OWNER UserRole = 6 )
Definitions of UserRole Values - OWNER being the highest, INACTIVE being the lowest
Variables ¶
This section is empty.
Functions ¶
func ConnectToDB ¶
ConnectToDB - Initialize and Start Database Connection
func InsertGameUserAssoc ¶
InsertGameUserAssoc - insert an association in the table between the game and the user passed in
func InsertUserMessageAssoc ¶
InsertUserMessageAssoc - insert an association in the table between the message and the user passed in
func IsInGameDB ¶
IsInGameDB - checks if a game exists in the database
func IsInUserDB ¶
IsInUserDB - checks if a user exists in the database
func UpdateMessage ¶
UpdateMessage - Update a Message (if it exists?)
Types ¶
type Game ¶
type Game struct { ID uint64 `gorm:"PRIMARY_KEY"` Name string `gorm:"UNIQUE;NOT NULL"` MaxPlayers uint8 Owners []User `gorm:"many2many:GameUser;"` }
Game - represents a game in the database
func SelectGame ¶
SelectGame - return a game Object in the database
func SelectGamesForPlayerCount ¶
SelectGamesForPlayerCount - Select the games objects that have at least the player count indicated
type Message ¶
type Message struct { ID uint64 `gorm:"PRIMARY_KEY"` DateFirstSent time.Time MessageContent string `gorm:"UNIQUE;NOT NULL"` Senders []User `gorm:"many2many:MessageUser;"` }
Message - represents a message in the database
func SelectMessage ¶
SelectMessage - return a Message Object in the database
type User ¶
type User struct { ID uint64 `gorm:"PRIMARY_KEY"` DiscordID string `gorm:"UNIQUE;NOT NULL"` Username string `gorm:"NOT NULL"` Nickname string `gorm:"NOT NULL"` RealName string `gorm:"NOT NULL"` Role UserRole `gorm:"DEFAULT:0"` Games []Game `gorm:"many2many:GameUser;"` Messages []Message `gorm:"many2many:MessageUser;"` }
User - represents a user in the database
func SelectUser ¶
SelectUser - return a User Object in the database by the primary key, discordID
func SelectUserByNickname ¶
SelectUserByNickname - select the first user that has the nickname indicated
func SelectUserByUsername ¶
SelectUserByUsername - select the first user that has the username indicated