Documentation ¶
Index ¶
- Constants
- func CoordToPlain(x, y, z int) int64
- func EnableWAL(db *sql.DB) error
- func MigrateBlockDB(db *sql.DB, dbtype types.DatabaseType) error
- func MigrateModStorageDB(db *sql.DB, dbtype types.DatabaseType) error
- func MigratePlayerDB(db *sql.DB, dbtype types.DatabaseType) error
- func PlainToCoord(i int64) (x, y, z int)
- type Block
- type BlockRepository
- type Context
- type ModStorageEntry
- type ModStorageRepository
- type Player
- type PlayerInventories
- type PlayerInventoryItems
- type PlayerMetadata
- type PlayerRepository
- type PlayerSqliteRepository
Examples ¶
Constants ¶
View Source
const (
MinPlainCoord = -34351347711
)
Variables ¶
This section is empty.
Functions ¶
func CoordToPlain ¶ added in v1.1.2
func MigrateBlockDB ¶ added in v1.1.2
func MigrateBlockDB(db *sql.DB, dbtype types.DatabaseType) error
func MigrateModStorageDB ¶ added in v1.1.22
func MigrateModStorageDB(db *sql.DB, dbtype types.DatabaseType) error
func MigratePlayerDB ¶ added in v1.1.23
func MigratePlayerDB(db *sql.DB, dbtype types.DatabaseType) error
func PlainToCoord ¶ added in v1.1.2
Types ¶
type BlockRepository ¶ added in v1.1.2
type BlockRepository interface { GetByPos(x, y, z int) (*Block, error) Update(block *Block) error Delete(x, y, z int) error }
func NewBlockRepository ¶ added in v1.1.2
func NewBlockRepository(db *sql.DB, dbtype types.DatabaseType) BlockRepository
type Context ¶ added in v1.1.20
type Context struct { Auth *auth.AuthRepository Privs *auth.PrivRepository Player PlayerRepository Blocks BlockRepository ModStorage ModStorageRepository // contains filtered or unexported fields }
Example ¶
package main import ( "fmt" "github.com/minetest-go/mtdb" ) func main() { // create a new context (an object with all repositories) from a minetest world-directory ctx, err := mtdb.New("/xy") if err != nil { panic(err) } // retrieve an auth entry of the "admin" user entry, err := ctx.Auth.GetByUsername("admin") if err != nil { panic(err) } fmt.Printf("Admin password-entry: %s\n", entry.Password) // retrieve admin's privileges privs, err := ctx.Privs.GetByID(*entry.ID) for _, priv := range privs { fmt.Printf(" + %s\n", priv.Privilege) } // get a mapblock from the database block, err := ctx.Blocks.GetByPos(0, 0, 0) if err != nil { panic(err) } // dump the raw and unparsed binary data // use the github.com/minetest-go/mapparser project to parse the actual content fmt.Printf("Mapblock content: %s\n", block.Data) }
Output:
type ModStorageEntry ¶ added in v1.1.21
type ModStorageEntry struct { ModName string `json:"modname"` Key []byte `json:"key"` Value []byte `json:"value"` }
internal name: "entries"
type ModStorageRepository ¶ added in v1.1.21
type ModStorageRepository interface { Get(modname string, key []byte) (*ModStorageEntry, error) Create(entry *ModStorageEntry) error Update(entry *ModStorageEntry) error Delete(modname string, key []byte) error }
func NewModStorageRepository ¶ added in v1.1.21
func NewModStorageRepository(db *sql.DB, dbtype types.DatabaseType) ModStorageRepository
type Player ¶ added in v1.1.21
type Player struct { Name string `json:"name"` Pitch float64 `json:"pitch"` Yaw float64 `json:"yaw"` PosX float64 `json:"posx"` PosY float64 `json:"posy"` PosZ float64 `json:"posz"` HP int `json:"hp"` Breath int `json:"breath"` CreationDate int64 `json:"creation_date"` ModificationDate int64 `json:"modification_date"` }
type PlayerInventories ¶ added in v1.1.21
type PlayerInventoryItems ¶ added in v1.1.21
type PlayerMetadata ¶ added in v1.1.21
type PlayerRepository ¶ added in v1.1.22
func NewPlayerRepository ¶ added in v1.1.22
func NewPlayerRepository(db *sql.DB, dbtype types.DatabaseType) PlayerRepository
type PlayerSqliteRepository ¶ added in v1.1.24
type PlayerSqliteRepository struct {
// contains filtered or unexported fields
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.