Documentation ¶
Index ¶
- type Card
- type CardCreate
- type CardManager
- type CardUpdate
- type DB
- func (db *DB) CreateCard(cardCreate *CardCreate) (int64, error)
- func (db *DB) CreateSet(setCreate *SetCreate) (*Set, error)
- func (db *DB) GetAllCards() ([]*Card, error)
- func (db *DB) GetCardByCardName(cardName string) (*Card, error)
- func (db *DB) GetCardsByCardType(cardType string) ([]*Card, error)
- func (db *DB) UpdateCard(cardUpdate *CardUpdate) (int64, error)
- type DatabaseManager
- type NullBoolJSON
- type NullInt64JSON
- type NullStringJSON
- type NullTimeJSON
- type Set
- type SetCreate
- type SetManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Card ¶
type Card struct { CardID int64 `json:"cardId"` CardName string `json:"cardName"` CardType string `json:"cardType"` CardArtist string `json:"cardArtist"` CardEffect NullStringJSON `json:"cardEffect,omitempty"` CardPower NullInt64JSON `json:"cardPower,omitempty"` CardIntelligence NullInt64JSON `json:"cardIntelligence,omitempty"` CardEndurance NullInt64JSON `json:"cardEndurance,omitempty"` }
---------------------------------
Data Structures
---------------------------------- Card describes the required and optional data needed to create a new card in our card table
type CardCreate ¶
type CardCreate struct { CardName string `json:"cardName"` CardType string `json:"cardType"` CardArtist string `json:"cardArtist"` CardEffect NullStringJSON `json:"cardEffect,omitempty"` CardPower NullInt64JSON `json:"cardPower,omitempty"` CardIntelligence NullInt64JSON `json:"cardIntelligence,omitempty"` CardEndurance NullInt64JSON `json:"cardEndurance,omitempty"` }
CardCreate describes the data needed to create a given card in our db
type CardManager ¶
type CardManager interface { GetAllCards() ([]*Card, error) GetCardsByCardType(cardType string) ([]*Card, error) GetCardByCardName(cardName string) (*Card, error) CreateCard(cardCreate *CardCreate) (int64, error) UpdateCard(cardUpdate *CardUpdate) (int64, error) }
CardManager describes all of the methods used to interact with the card table in our database
type CardUpdate ¶
type CardUpdate struct { CardID int64 `json:"cardId,omitempty"` CardName NullStringJSON `json:"cardName,omitempty"` CardType NullStringJSON `json:"cardType,omitempty"` CardArtist NullStringJSON `json:"cardArtist,omitempty"` CardEffect NullStringJSON `json:"cardEffect,omitempty"` CardPower NullInt64JSON `json:"cardPower,omitempty"` CardIntelligence NullInt64JSON `json:"cardIntelligence,omitempty"` CardEndurance NullInt64JSON `json:"cardEndurance,omitempty"` }
CardUpdate describes the data needed to update a given card in our db
type DB ¶
DB is the struct that we're going to use to implement all of our Datasbase interfaces; All of the methods defined on each of our interfaces will be implemented on this DB struct
func New ¶
New initializes a new postgres database connection and attaches said connection to our DB struct, which we can then call all of the methods described by the our varies Database interfaces
func (*DB) CreateCard ¶
func (db *DB) CreateCard(cardCreate *CardCreate) (int64, error)
CreateCard adds a new entry to the card table in our database
func (*DB) CreateSet ¶
---------------------------------
Method Implementations
---------------------------------- CreateSet adds a new entry to the card table in our database
func (*DB) GetAllCards ¶
GetAllCards fetches all cards in our db
func (*DB) GetCardByCardName ¶
GetCardByCardName fetches a specific card by its name from the db
func (*DB) GetCardsByCardType ¶
GetCardsByCardType fetches all cards with a specific type
func (*DB) UpdateCard ¶
func (db *DB) UpdateCard(cardUpdate *CardUpdate) (int64, error)
UpdateCard updates an existing entry in the cards table
type DatabaseManager ¶
type DatabaseManager interface { CardManager SetManager }
DatabaseManager combines all of the database interactions into one
type NullBoolJSON ¶
NullBoolJSON extends sql.NullBool to nicely (Un)Marshal JSON
func (*NullBoolJSON) MarshalJSON ¶
func (nb *NullBoolJSON) MarshalJSON() ([]byte, error)
MarshalJSON handles sql.NullBool to JSON
func (*NullBoolJSON) UnmarshalJSON ¶
func (nb *NullBoolJSON) UnmarshalJSON(data []byte) error
UnmarshalJSON handles JSON to sql.NullBool
type NullInt64JSON ¶
NullInt64JSON extends sql.NullInt64 to nicely (Un)Marshal JSON
func (*NullInt64JSON) MarshalJSON ¶
func (ni *NullInt64JSON) MarshalJSON() ([]byte, error)
MarshalJSON handles sql.NullInt64 to JSON
func (*NullInt64JSON) UnmarshalJSON ¶
func (ni *NullInt64JSON) UnmarshalJSON(data []byte) error
UnmarshalJSON handles JSON to sql.NullInt64
type NullStringJSON ¶
type NullStringJSON struct {
sql.NullString
}
NullStringJSON extends sql.NullString to nicely (Un)Marshal JSON
func (*NullStringJSON) MarshalJSON ¶
func (ns *NullStringJSON) MarshalJSON() ([]byte, error)
MarshalJSON handles sql.NullString to JSON
func (*NullStringJSON) UnmarshalJSON ¶
func (ns *NullStringJSON) UnmarshalJSON(data []byte) error
UnmarshalJSON handles JSON to sql.NullString
type NullTimeJSON ¶
NullTimeJSON extends pq.NullTime to nicely (Un)Marshal JSON
func (*NullTimeJSON) MarshalJSON ¶
func (nt *NullTimeJSON) MarshalJSON() ([]byte, error)
MarshalJSON handles pq.NullTime to JSON
func (*NullTimeJSON) UnmarshalJSON ¶
func (nt *NullTimeJSON) UnmarshalJSON(data []byte) error
UnmarshalJSON handles JSON to pq.NullTime
type Set ¶
---------------------------------
Data Structures
---------------------------------- Set describes the required and optional data needed to create a new set in our set table
type SetCreate ¶
type SetCreate struct {
SetName string `json:"setName"`
}
SetCreate describes the data needed to create a given set in our db
type SetManager ¶
SetNabager describes all of the methods used to interact with the set table in our database