deck

package
v1.4.9 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2025 License: Unlicense Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BoardMainboard = "mainBoard"
	BoardSideboard = "sideBoard"
	BoardCommander = "commander"
)

Variables

This section is empty.

Functions

func AddCards added in v1.1.9

func AddCards(database *server.Database, deck *deckModel.Deck, contents *deckModel.DeckContentIds) error

AddCards - Add cards to a deck within the database. Deck must have a Deck Code associated with it or it will error out. Does not validate cards

func AllCardIds added in v1.1.9

func AllCardIds(contents *deckModel.DeckContentIds) []string

AllCardIds - Takes a deckModel.DeckContentIds structure and retuns a single slice of strings representing all the cardIds across each board

func DeleteDeck

func DeleteDeck(database *server.Database, code string, owner string) error

DeleteDeck Remove a deck from the MongoDB database using the code passed in the parameter. Returns ErrNoDeck if the deck does not exist. Returns ErrDeckDeleteFailed if the deleted count does not equal 1

func GetDeck

func GetDeck(database *server.Database, code string, owner string) (*deckModel.Deck, error)

GetDeck Fetch a deck from the MongoDB database using the code passed in the parameter. Owner is the email address of the user that you want to assign to the deck. If the string is empty then it does not filter by user. Returns ErrNoDeck if the deck does not exist or cannot be located

func GetDeckContents added in v1.0.1

func GetDeckContents(database *server.Database, deck *deckModel.Deck) (*deckModel.DeckContents, error)

GetDeckContents - Iterates through all the boards in a deck and fetches the card models for each of the cards. First all the cardID's across all boards are appended to a single list and a single database call is consumed to fetch them down. Then they are iterated over and each board is checked for the ID, if it is found then it is added its respective board as a deckModel.DeckContentEntry structure

func IndexDecks added in v1.0.1

func IndexDecks(database *server.Database, limit int64) ([]*deckModel.Deck, error)

IndexDecks Returns all decks in the database unmarshalled as deck models. The limit parameter will be passed directly to the database query to limit the number of models returned

func NewDeck

func NewDeck(database *server.Database, deck *deckModel.Deck, owner string) error

NewDeck Insert a new deck in the form of a model into the MongoDB database. The deck model must have a valid name and deck code, additionally the deck cannot already exist under the same deck code. Owner is the email address of the owner you want to assign the deck to. If the string is empty, it will be assigned to the system user

func RemoveCards added in v1.1.9

func RemoveCards(database *server.Database, deck *deckModel.Deck, contents *deckModel.DeckContentIds) error

RemoveCards - Remove cards from a specified board. Does not validate cards

func ReplaceDeck added in v1.0.1

func ReplaceDeck(database *server.Database, deck *deckModel.Deck) error

ReplaceDeck Replace the entire deck in the database with the deck model passed in the parameter. Returns ErrDeckUpdateFailed if the deck cannot be located

Types

This section is empty.

Jump to

Keyboard shortcuts

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