models

package
v0.0.0-...-9a7d2f5 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	ID          int64          `db:"id" json:"id"`
	Name        string         `db:"name" json:"name"`
	Description string         `db:"description" json:"description"`
	Cost        int64          `db:"cost" json:"cost"`
	Rarity      string         `db:"rarity" json:"rarity"`
	Categories  pq.StringArray `db:"categories" json:"categories"`
}

type ItemModel

type ItemModel struct {
	Db *sqlx.DB
}

func (*ItemModel) CreateItem

func (im *ItemModel) CreateItem(item Item) (int64, error)

func (*ItemModel) GetItem

func (im *ItemModel) GetItem(id int64) (Item, error)

func (*ItemModel) GetItemByName

func (im *ItemModel) GetItemByName(name string) (Item, error)

func (*ItemModel) PageItems

func (im *ItemModel) PageItems(offset, limit int) ([]Item, error)

Will return all items in the database within the pagination range Hard Set Limit of 100 items per page, and default page size is 10

func (*ItemModel) QueryItems

func (im *ItemModel) QueryItems(query string, page, limit int) ([]Item, error)

func (*ItemModel) UpdateItem

func (im *ItemModel) UpdateItem(item Item) error

type Models

type Models struct {
	ItemModel *ItemModel
	// contains filtered or unexported fields
}

func NewModels

func NewModels(Db *sqlx.DB) *Models

Jump to

Keyboard shortcuts

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