db

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WORLD       = "World"
	AREA        = "Area"
	LOCATION    = "Location"
	SUBLOCATION = "Sublocation"
)
View Source
const DEFAULT_PATH = "/.config/lorecli/sqlite.db"

Variables

This section is empty.

Functions

func OpenDb

func OpenDb(cfg *config.Config) (*sql.DB, error)

Types

type Area

type Area struct {
	Name    string
	Desc    string
	Type    string
	Id      int
	WorldId int
}

func (*Area) Inspect

func (a *Area) Inspect() (int, string)

func (*Area) PlaceType

func (a *Area) PlaceType() PlaceType

type AreaParams

type AreaParams struct {
	Name    string
	Desc    string
	Type    string
	WorldId int
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type Location

type Location struct {
	Name   string
	Type   string
	Desc   string
	Id     int
	AreaId int
}

func (*Location) Inspect

func (l *Location) Inspect() (int, string)

func (*Location) PlaceType

func (l *Location) PlaceType() PlaceType

type LocationParams

type LocationParams struct {
	Name   string
	Type   string
	Desc   string
	AreaId int
}

type Npc

type Npc struct {
	Name        string
	Race        string
	Class       string
	Subclass    string
	Alignment   string
	Sex         string
	Description string
	Languages   string
	Id          int
	Level       int
	Hitpoints   int
	WorldId     int
}

type NpcParams

type NpcParams struct {
	Name        string
	Race        string
	Class       string
	Subclass    string
	Alignment   string
	Sex         string
	Description string
	Languages   string
	Level       int
	Hitpoints   int
	WorldId     int
}

type Place

type Place interface {
	PlaceType() PlaceType
	Inspect() (int, string)
}

type PlaceType

type PlaceType string

type Queries

type Queries struct {
	Db DBTX
}

func New

func New(db DBTX) *Queries

func (*Queries) AddArea

func (q *Queries) AddArea(
	ctx context.Context,
	params *AreaParams,
) (*Area, error)

func (*Queries) AddLocation

func (q *Queries) AddLocation(
	ctx context.Context,
	params *LocationParams,
) (*Location, error)

func (*Queries) AddNpc

func (q *Queries) AddNpc(ctx context.Context, params *NpcParams) (*Npc, error)

func (*Queries) AddQuest added in v0.3.0

func (q *Queries) AddQuest(
	ctx context.Context,
	p *QuestParams,
) (*Quest, error)

func (*Queries) AddSublocation

func (q *Queries) AddSublocation(
	ctx context.Context,
	params *SublocationParams,
) (*Sublocation, error)

func (*Queries) AddWorld

func (q *Queries) AddWorld(
	ctx context.Context,
	params *WorldParams,
) (*World, error)

func (*Queries) DeleteAreaByIdQuery

func (q *Queries) DeleteAreaByIdQuery(ctx context.Context, id int) error

func (*Queries) DeleteLocationByIdQuery

func (q *Queries) DeleteLocationByIdQuery(ctx context.Context, id int) error

func (*Queries) DeleteNpcById added in v0.3.0

func (q *Queries) DeleteNpcById(
	ctx context.Context,
	id int,
) error

func (*Queries) DeleteQuestById added in v0.3.0

func (q *Queries) DeleteQuestById(ctx context.Context, id int) error

func (*Queries) DeleteWorldByIdQuery

func (q *Queries) DeleteWorldByIdQuery(ctx context.Context, id int) error

func (*Queries) EditNpcById

func (q *Queries) EditNpcById(
	ctx context.Context,
	npc *Npc,
) (*Npc, error)

func (*Queries) GetAllAreas added in v0.3.0

func (q *Queries) GetAllAreas(ctx context.Context) ([]*Area, error)

func (*Queries) GetAllLocations added in v0.3.0

func (q *Queries) GetAllLocations(ctx context.Context) ([]*Location, error)

func (*Queries) GetAreaByName

func (q *Queries) GetAreaByName(
	ctx context.Context,
	name string,
) (*Area, error)

func (*Queries) GetLocationByName

func (q *Queries) GetLocationByName(
	ctx context.Context,
	name string,
) (*Location, error)

func (*Queries) GetNpcById added in v0.3.0

func (q *Queries) GetNpcById(
	ctx context.Context,
	id int,
) (*Npc, error)

func (*Queries) GetQuestByIdQuery added in v0.3.0

func (q *Queries) GetQuestByIdQuery(
	ctx context.Context,
	id int,
) (*Quest, error)

func (*Queries) GetQuestsByName added in v0.3.0

func (q *Queries) GetQuestsByName(
	ctx context.Context,
	name string,
) ([]*Quest, error)

func (*Queries) GetSublocationByName

func (q *Queries) GetSublocationByName(
	ctx context.Context,
	name string,
) (*Sublocation, error)

func (*Queries) GetWorldByName

func (q *Queries) GetWorldByName(
	ctx context.Context,
	name string,
) (*World, error)

func (*Queries) GetXAreas

func (q *Queries) GetXAreas(
	ctx context.Context,
	worldId int,
	x int,
	offset int,
) ([]*Area, error)

func (*Queries) GetXLocations

func (q *Queries) GetXLocations(
	ctx context.Context,
	x int,
	offset int,
) ([]*Location, error)

func (*Queries) GetXQuests added in v0.3.0

func (q *Queries) GetXQuests(
	ctx context.Context,
	x int,
	offset int,
) ([]*Quest, error)

func (*Queries) GetXWorlds

func (q *Queries) GetXWorlds(
	ctx context.Context,
	x int,
	offset int,
) ([]*World, error)

func (*Queries) SearchAreasByName

func (q *Queries) SearchAreasByName(
	ctx context.Context,
	params SearchParams,
) ([]*Area, error)

func (*Queries) SearchLocationsByName

func (q *Queries) SearchLocationsByName(
	ctx context.Context,
	params SearchParams,
) ([]*Location, error)

func (*Queries) SearchNpcsByName

func (q *Queries) SearchNpcsByName(
	ctx context.Context,
	name string,
) ([]*Npc, error)

func (*Queries) SearchWorldsByName

func (q *Queries) SearchWorldsByName(
	ctx context.Context,
	params SearchParams,
) ([]*World, error)

func (*Queries) UpdateAreaById

func (q *Queries) UpdateAreaById(
	ctx context.Context,
	area Area,
) (*Area, error)

func (*Queries) UpdateLocationById

func (q *Queries) UpdateLocationById(
	ctx context.Context,
	location Location,
) (*Location, error)

func (*Queries) UpdateQuestById added in v0.3.0

func (q *Queries) UpdateQuestById(
	ctx context.Context,
	p UpdateQuestParams,
) (*Quest, error)

func (*Queries) UpdateWorldById

func (q *Queries) UpdateWorldById(
	ctx context.Context,
	world World,
) (*World, error)

func (*Queries) ViewNpcByName

func (q *Queries) ViewNpcByName(
	ctx context.Context,
	name string,
) (*Npc, error)

func (*Queries) WorldCount added in v0.2.1

func (q *Queries) WorldCount(ctx context.Context) (int, error)

type Quest added in v0.3.0

type Quest struct {
	Name       string
	Desc       string
	Rewards    string
	Notes      string
	Level      int
	IsStarted  bool
	IsFinished bool
	WorldId    int
	Id         int
}

type QuestParams added in v0.3.0

type QuestParams struct {
	Name       string
	Desc       string
	Rewards    string
	Notes      string
	Level      int
	IsStarted  bool
	IsFinished bool
	WorldId    int
}

type SearchParams

type SearchParams struct {
	Name   string
	Limit  int
	Offset int
}

type Sublocation

type Sublocation struct {
	Name       string
	Type       string
	Desc       string
	Id         int
	LocationId int
}

func (*Sublocation) Inspect

func (s *Sublocation) Inspect() (int, string)

func (*Sublocation) PlaceType

func (s *Sublocation) PlaceType() PlaceType

type SublocationParams

type SublocationParams struct {
	Name       string
	Type       string
	Desc       string
	LocationId string
}

type UpdateQuestParams added in v0.3.0

type UpdateQuestParams struct {
	Name       string
	Desc       string
	Rewards    string
	Notes      string
	Level      int
	IsStarted  bool
	IsFinished bool
	WorldId    int
	Id         int
}

type World

type World struct {
	Name string
	Desc string
	Id   int
}

func (*World) Inspect

func (w *World) Inspect() (int, string)

func (*World) PlaceType

func (w *World) PlaceType() PlaceType

type WorldParams

type WorldParams struct {
	Name string
	Desc string
}

Jump to

Keyboard shortcuts

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