gorm

package
v0.0.0-...-0f828a4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseRepository

type BaseRepository struct {
	Db *gorm.DB
}

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

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

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.

Jump to

Keyboard shortcuts

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