db

package
v0.0.0-...-869fae9 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect() (*pgx.Conn, error)

func Pool

func Pool() (*pgxpool.Pool, error)

func Reset

func Reset(opts ResetOpts) error

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

func NewDB

func NewDB() (*DB, error)

func (*DB) ContainerFor

func (db *DB) ContainerFor(o Object) (oo *Object, err error)

func (*DB) Derez

func (db *DB) Derez(uid uint32) (err error)

func (*DB) Ensure

func (db *DB) Ensure() error

Ensure checks for and then creates default resources if they do not exist (like the Foyer)

func (*DB) Erase

func (db *DB) Erase() (err error)

Erase fully destroys the database's contents, dropping all tables.

func (*DB) GetAvatarForUid

func (db *DB) GetAvatarForUid(uid uint32) (av *Object, err error)

func (*DB) GetObject

func (db *DB) GetObject(owneruid uint32, name string) (obj *Object, err error)

func (*DB) GetObjectByID

func (db *DB) GetObjectByID(ID int) (*Object, error)

func (*DB) GhostBust

func (db *DB) GhostBust() error

func (*DB) GreateAvatar

func (db *DB) GreateAvatar(uid uint32, name string) (av *Object, err error)

func (*DB) ObjectByID

func (db *DB) ObjectByID(id int) (*Object, error)

func (*DB) ObjectByOwnerName

func (db *DB) ObjectByOwnerName(ownerid uint32, name string) (*Object, error)

func (*DB) Resolve

func (db *DB) Resolve(vantage Object, term string) ([]Object, error)

func (*DB) SearchObjectsByName

func (db *DB) SearchObjectsByName(term string) ([]Object, error)

type Object

type Object struct {
	// TODO eventually I want uint64 for ids
	ID      int
	Avatar  bool
	Bedroom bool
	OwnerID int
	Perms   *Permissions

	Data map[string]interface{}
	// contains filtered or unexported fields
}

func Filter

func Filter(os []*Object, term string) []*Object

func NewAvatar

func NewAvatar(owneruid uint32, username string) *Object

func NewBedroom

func NewBedroom(owneruid uint32, username string) *Object

func NewObject

func NewObject(owneruid uint32) *Object

types. i had parallel thoughts: all map data is strings and objects can have numbers, too. those are incompatible. i don't remember what i did in tildemush for this.

the ideal user experience is that types "just work." so something like this:

--[[WITCH data:

foo: 1
bar: "hi"

--[[HCTIW

hears(".*", function()

set("foo", get("foo") + 1)
say(my("bar"))

end)

i've hacked things such that this could work if i dynamically figure out types stored in data at run time.

the more i play with editing scripts the less happy i ham with the comment approach and, indeed, the approach of having the data right there in the code.

i might feel better about it if it looked like tildemush again -- (has) etc. s expression parsing just makes me feel less nervous even if conceptually it's just as brittle.

but something to consider is that i'm locking people into editing in the application -- so why not have object editing have UI elements for data and permissions?

i'm using the browser as inspiration and remembering how in the dev console you get code and also a javascript object explorer.

i'm going to ruminate on that.

func NewRoom

func NewRoom(owneruid uint32) *Object

func (*Object) AppendScript

func (o *Object) AppendScript(code string)

func (*Object) Can

func (o *Object) Can(perm string, other Object) bool

func (*Object) Container

func (o *Object) Container(db *DB) (*Object, error)

func (*Object) Contents

func (o *Object) Contents(db *DB) ([]*Object, error)

func (*Object) Create

func (o *Object) Create(db *DB) error

func (*Object) Earshot

func (o *Object) Earshot(db *DB) ([]*Object, error)

func (*Object) GetDataString

func (o *Object) GetDataString(key string) string

func (*Object) GetScript

func (o *Object) GetScript() string

func (*Object) HasSameOwner

func (o *Object) HasSameOwner(other Object) bool

func (*Object) MoveInto

func (o *Object) MoveInto(db *DB, container Object) error

func (*Object) Refresh

func (o *Object) Refresh(db *DB) error

func (*Object) SetData

func (o *Object) SetData(key string, value string)

func (*Object) SetScript

func (o *Object) SetScript(code string) error

func (*Object) String

func (o *Object) String() string

func (*Object) Update

func (o *Object) Update(db *DB) error

type Perm

type Perm string
const (
	PermWorld Perm = "world"
	PermOwner Perm = "owner"
)

type Permissions

type Permissions struct {
	Read  Perm
	Write Perm
	Carry Perm
	Exec  Perm
}

type ResetOpts

type ResetOpts struct {
	DB *DB
}

Jump to

Keyboard shortcuts

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