data

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver interface {
	IsForeignKeyViolation(err error) bool
	IsUniqueViolation(err error) bool
}

type ItemDriver

type ItemDriver interface {
	Driver
	ListQuery(asset.ItemFilter) string
	GetQuery() string
	CreateQuery() string
	UpdateQuery() string
	RemoveQuery() string
}

ItemDriver abstracts away the SQL driver specific functionality.

type ItemStorage

type ItemStorage struct {
	DB     *sql.DB
	Driver ItemDriver
}

ItemStorage is used to manage the persistent storage of item data.

func (ItemStorage) Create

func (i ItemStorage) Create(ctx context.Context, create asset.ItemCreate) (*asset.Item, error)

Create persists a new item, returning item information including the newly created itemID.

func (ItemStorage) Get

func (i ItemStorage) Get(ctx context.Context, itemID asset.ItemID) (*asset.Item, error)

Get returns a item given the itemID.

func (ItemStorage) List

func (i ItemStorage) List(ctx context.Context, filter asset.ItemFilter) ([]*asset.Item, error)

List returns a slice of items based on the balue of the filter.

func (ItemStorage) Remove

func (i ItemStorage) Remove(ctx context.Context, itemID asset.ItemID) error

Remove deletes the item from persistent storage.

func (ItemStorage) Update

func (i ItemStorage) Update(ctx context.Context, itemID asset.ItemID, update asset.ItemUpdate) (*asset.Item, error)

Update updates a item, return the updated item.

type LinkDriver

type LinkDriver interface {
	Driver
	ListQuery(asset.LinkFilter) string
	GetQuery() string
	CreateQuery() string
	UpdateQuery() string
	RemoveQuery() string
}

LinkDriver abstracts away the SQL driver specific functionality.

type LinkStorage

type LinkStorage struct {
	DB     *sql.DB
	Driver LinkDriver
}

LinkStorage is used to manage the persistent storage of link data.

func (LinkStorage) Create

func (l LinkStorage) Create(ctx context.Context, create asset.LinkCreate) (*asset.Link, error)

Create persists a new link, returning link information including the newly created linkID.

func (LinkStorage) Get

func (l LinkStorage) Get(ctx context.Context, linkID asset.LinkID) (*asset.Link, error)

Get returns a link given the linkID.

func (LinkStorage) List

func (l LinkStorage) List(ctx context.Context, filter asset.LinkFilter) ([]*asset.Link, error)

List returns a slice of links based on the balue of the filter.

func (LinkStorage) Remove

func (l LinkStorage) Remove(ctx context.Context, linkID asset.LinkID) error

Remove deletes the link from persistent storage.

func (LinkStorage) Update

func (l LinkStorage) Update(ctx context.Context, linkID asset.LinkID, update asset.LinkUpdate) (*asset.Link, error)

Update updates a link, return the updated link.

type PlayerDriver

type PlayerDriver interface {
	Driver
	ListQuery(asset.PlayerFilter) string
	GetQuery() string
	CreateQuery() string
	UpdateQuery() string
	RemoveQuery() string
}

PlayerDriver abstracts away the SQL driver specific functionality.

type PlayerStorage

type PlayerStorage struct {
	DB     *sql.DB
	Driver PlayerDriver
}

PlayerStorage is used to manage the persistent storage of player data.

func (PlayerStorage) Create

func (p PlayerStorage) Create(ctx context.Context, create asset.PlayerCreate) (*asset.Player, error)

Create persists a new player, returning player information including the newly created playerID.

func (PlayerStorage) Get

func (p PlayerStorage) Get(ctx context.Context, playerID asset.PlayerID) (*asset.Player, error)

Get returns a player given the playerID.

func (PlayerStorage) List

func (p PlayerStorage) List(ctx context.Context, filter asset.PlayerFilter) ([]*asset.Player, error)

List returns a slice of players based on the balue of the filter.

func (PlayerStorage) Remove

func (p PlayerStorage) Remove(ctx context.Context, playerID asset.PlayerID) error

Remove deletes the player from persistent storage.

func (PlayerStorage) Update

func (p PlayerStorage) Update(ctx context.Context, playerID asset.PlayerID, update asset.PlayerUpdate) (*asset.Player, error)

Update updates a player, return the updated player.

type RoomDriver

type RoomDriver interface {
	Driver
	ListQuery(asset.RoomFilter) string
	GetQuery() string
	CreateQuery() string
	UpdateQuery() string
	RemoveQuery() string
}

RoomDriver abstracts away the SQL driver specific functionality.

type RoomStorage

type RoomStorage struct {
	DB     *sql.DB
	Driver RoomDriver
}

RoomStorage is used to manage the persistent storage of room data.

func (RoomStorage) Create

func (r RoomStorage) Create(ctx context.Context, create asset.RoomCreate) (*asset.Room, error)

Create persists a new room, returning room information including the newly created roomID.

func (RoomStorage) Get

func (r RoomStorage) Get(ctx context.Context, roomID asset.RoomID) (*asset.Room, error)

Get returns a room given the roomID.

func (RoomStorage) List

func (r RoomStorage) List(ctx context.Context, filter asset.RoomFilter) ([]*asset.Room, error)

List returns a slice of rooms based on the balue of the filter.

func (RoomStorage) Remove

func (r RoomStorage) Remove(ctx context.Context, roomID asset.RoomID) error

Remove deletes the room from persistent storage.

func (RoomStorage) Update

func (r RoomStorage) Update(ctx context.Context, roomID asset.RoomID, update asset.RoomUpdate) (*asset.Room, error)

Update updates a room, return the updated room.

type UserDriver added in v0.1.2

type UserDriver interface {
	Driver
	ListQuery(user.Filter) string
	GetQuery() string
	CreateQuery() string
	UpdateQuery() string
	AssociatePlayerQuery() string
	RemoveQuery() string
}

UserDriver abstracts away the SQL driver specific functionality.

type UserStorage added in v0.1.2

type UserStorage struct {
	DB     *sql.DB
	Driver UserDriver
}

UserStorage is used to manage the persistent storage of user data.

func (UserStorage) AssociatePlayer added in v0.2.7

func (u UserStorage) AssociatePlayer(ctx context.Context, userID user.ID, assoc user.AssociatePlayer) (*user.User, error)

AssociatePlayer associates a player with the user, returning the updated user.

func (UserStorage) Create added in v0.1.2

func (u UserStorage) Create(ctx context.Context, create user.Create) (*user.User, error)

Create persists a new user, returning user information including the newly created userID.

func (UserStorage) Get added in v0.1.2

func (u UserStorage) Get(ctx context.Context, userID user.ID) (*user.User, error)

Get returns a user given the userID.

func (UserStorage) List added in v0.1.2

func (u UserStorage) List(ctx context.Context, filter user.Filter) ([]*user.User, error)

List returns a slice of users based on the balue of the filter.

func (UserStorage) Remove added in v0.1.2

func (u UserStorage) Remove(ctx context.Context, userID user.ID) error

Remove deletes the user from persistent storage.

func (UserStorage) Update added in v0.1.2

func (u UserStorage) Update(ctx context.Context, userID user.ID, update user.Update) (*user.User, error)

Update updates a user, return the updated user.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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