storage

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host string
	Port string
	Name string
	User string
	Pass string
}

Config stores configuration for the database.

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database stores information about the database connection.

func Connect

func Connect(config Config) (*Database, error)

Connect : Connects to a MongoDB database and returns a database struct.

func (Database) CreateUser

func (db Database) CreateUser(userInfo User) (err error)

CreateUser creates the user in the database.

func (Database) EnsureUser

func (db Database) EnsureUser(guildid, userid string) (user User, err error)

EnsureUser checks if the user exists in the database, if not it will create the user in the database.

func (Database) GetTopUser

func (db Database) GetTopUser(guildid string) (User, error)

GetTopUser returns a user struct containing user data of the user with the most tacos in the guild.

func (Database) GetUser

func (db Database) GetUser(userid, guildid string) (user User, err error)

GetUser returns a user struct containing user data.

func (Database) IsUserInDatabase

func (db Database) IsUserInDatabase(userid, guildid string) (bool, error)

IsUserInDatabase checks if the user is in the database.

func (Database) UpdateUser

func (db Database) UpdateUser(user User) (err error)

UpdateUser updates a user's account data.

type User

type User struct {
	GuildID string `bson:"guildid"`
	UserID  string `bson:"userid"`
	Balance int    `bson:"balance"`
}

User stores information about the user.

Jump to

Keyboard shortcuts

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