Documentation ¶
Index ¶
- type BaseRepository
- type DeckRepository
- func (d DeckRepository) Create(name string, creator uint, official bool, ...) repositories.RepositoryError
- func (d DeckRepository) Get(id uint, preloadCards bool) (models.Deck, repositories.RepositoryError)
- func (d DeckRepository) GetRandomAmountOfBlackCards(amount uint, deckIds []uint) ([]models.BlackCard, repositories.RepositoryError)
- func (d DeckRepository) GetRandomAmountOfWhiteCards(amount uint, deckIds []uint) ([]models.WhiteCard, repositories.RepositoryError)
- type UserRepository
- func (u UserRepository) Create(username, password string, admin bool) repositories.RepositoryError
- func (u UserRepository) DeleteById(id uint) repositories.RepositoryError
- func (u UserRepository) GenerateSessionToken(id uint) (models.SessionToken, repositories.RepositoryError)
- func (u UserRepository) GetById(id uint) (models.User, repositories.RepositoryError)
- func (u UserRepository) GetBySessionToken(sessionToken string) (models.User, repositories.RepositoryError)
- func (u UserRepository) GetByUsername(username string) (models.User, repositories.RepositoryError)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseRepository ¶
The base every gorm repository contains.
type DeckRepository ¶
type DeckRepository struct {
BaseRepository
}
A repository that is responsible for deck-related data.
func (DeckRepository) Create ¶
func (d DeckRepository) Create(name string, creator uint, official bool, blackCardsRaw, whiteCardsRaw []string) repositories.RepositoryError
Creates a deck from the supplied parameters. If the value of the creator is `0` (the default zero value for uint), it will be a non-existent value. At first, this function will convert the supplied card string into their corresponding models. Then it will create the decks.
func (DeckRepository) Get ¶
func (d DeckRepository) Get(id uint, preloadCards bool) (models.Deck, repositories.RepositoryError)
Gets a deck by id. If preloadCards is `true`, it will preload the black and white cards from the database.
func (DeckRepository) GetRandomAmountOfBlackCards ¶
func (d DeckRepository) GetRandomAmountOfBlackCards(amount uint, deckIds []uint) ([]models.BlackCard, repositories.RepositoryError)
Returns a random amount of black cards. See DeckRepository.getCardRandomAmount for more information.
func (DeckRepository) GetRandomAmountOfWhiteCards ¶
func (d DeckRepository) GetRandomAmountOfWhiteCards(amount uint, deckIds []uint) ([]models.WhiteCard, repositories.RepositoryError)
Returns a random amount of white cards. See DeckRepository.getCardRandomAmount for more information.
type UserRepository ¶
type UserRepository struct {
BaseRepository
}
A repository that is responsible for user-related data.
func (UserRepository) Create ¶
func (u UserRepository) Create(username, password string, admin bool) repositories.RepositoryError
Creates a models.User according to the supplied parameters.
func (UserRepository) DeleteById ¶
func (u UserRepository) DeleteById(id uint) repositories.RepositoryError
Deletes a models.User by using an id.
func (UserRepository) GenerateSessionToken ¶
func (u UserRepository) GenerateSessionToken(id uint) (models.SessionToken, repositories.RepositoryError)
Generates a session token for the supplied user id.
func (UserRepository) GetById ¶
func (u UserRepository) GetById(id uint) (models.User, repositories.RepositoryError)
Gets a models.User by using an id.
func (UserRepository) GetBySessionToken ¶
func (u UserRepository) GetBySessionToken(sessionToken string) (models.User, repositories.RepositoryError)
Returns a user by the provided session token. It will only search for tokens that are not expired, yet.
func (UserRepository) GetByUsername ¶
func (u UserRepository) GetByUsername(username string) (models.User, repositories.RepositoryError)
Gets a models.User by using an username.