dba

package
v0.0.0-...-0cb0207 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AccessModule = fx.Provide(func() (*DBAccess, error) {

	if session, err := mgo.Dial("0.0.0.0:27017"); err == nil {
		return NewDBAccess(session, databaseName), nil
	} else {
		return nil, err
	}

})

AccessModule ... exports dbaccess module

View Source
var RepositoryModule = fx.Provide(func(dba *DBAccess) *Repository {
	return &Repository{
		Avatars: NewAvatarDAO(dba),
		Rooms:   NewRoomDAO(dba),
		Worlds:  NewWorldDAO(dba),
	}
})

RepositoryModule ... exports dbaccess module

Functions

This section is empty.

Types

type AvatarDAO

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

AvatarDAO ... datatype for the ruleset

func NewAvatarDAO

func NewAvatarDAO(db *DBAccess) *AvatarDAO

NewAvatarDAO ... creates a new ruleset

func (*AvatarDAO) Delete

func (a *AvatarDAO) Delete(avatar AvatarDTO) error

Delete an avatar

func (*AvatarDAO) FindAll

func (a *AvatarDAO) FindAll() ([]AvatarDAO, error)

FindAll ... find all rooms

func (*AvatarDAO) FindByID

func (a *AvatarDAO) FindByID(id string) (AvatarDTO, error)

FindByID ... finds a room by id

func (*AvatarDAO) Insert

func (a *AvatarDAO) Insert(avatar AvatarDTO) error

Insert an AvatarDTO into the db

func (*AvatarDAO) InsertOrUpdate

func (a *AvatarDAO) InsertOrUpdate(avatar AvatarDTO) error

InsertOrUpdate ... insert or update an existing room by id

func (*AvatarDAO) Update

func (a *AvatarDAO) Update(avatar AvatarDTO) error

Update ... update an existing room by id

type AvatarDTO

type AvatarDTO struct {
	ID bson.ObjectId `json:"id,omitempty" bson:"_id,omitempty"`

	Name         string    `json:"name"`
	Description  string    `json:"description"`
	CreationDate time.Time `json:"creationDate,omitempty"`

	CurrentRoomID string `json:"lastKnownRoomID,omitempty" bson:"lastKnownRoomID,omitempty"`
	UserID        string `json:"userID"`
}

AvatarDTO ... dto to store data related to avatars Avatars can be either controlled by Players/Users or be attached/belong to bots Once a user is logged in he automatically gets attached his last used aavatar

func NewAvatarDTO

func NewAvatarDTO(name string, description string, userID string) *AvatarDTO

NewAvatarDTO ... creates and returns a new room instance

type DBAccess

type DBAccess struct {
	Session  *mgo.Session
	Database string
}

DBAccess ... datatype for the ruleset

func NewDBAccess

func NewDBAccess(session *mgo.Session, dbName string) *DBAccess

NewDBAccess ... creates a new ruleset

func (*DBAccess) C

func (dba *DBAccess) C(collection string) *mgo.Collection

C ... returns collection

func (*DBAccess) CreateDatabase

func (dba *DBAccess) CreateDatabase()

CreateDatabase ... creates initial database value

func (*DBAccess) DB

func (dba *DBAccess) DB() *mgo.Database

DB ... returns database instance

type Repository

type Repository struct {
	Rooms   *RoomDAO
	Avatars *AvatarDAO
	Worlds  *WorldDAO
}

Repository ... datatype for the ruleset

type RoomDAO

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

RoomDAO ... datatype for the ruleset

func NewRoomDAO

func NewRoomDAO(db *DBAccess) *RoomDAO

NewRoomDAO ... creates a new ruleset

func (*RoomDAO) Delete

func (r *RoomDAO) Delete(room RoomDTO) error

Delete ... delete a room

func (*RoomDAO) FindAll

func (r *RoomDAO) FindAll() ([]RoomDAO, error)

FindAll ... find all rooms

func (*RoomDAO) FindByID

func (r *RoomDAO) FindByID(id string) (RoomDTO, error)

FindByID ... finds a room by id

func (*RoomDAO) Insert

func (r *RoomDAO) Insert(room RoomDTO) error

Insert ... insert a room

func (*RoomDAO) Update

func (r *RoomDAO) Update(room RoomDTO) error

Update ... update an existing room by id

type RoomDTO

type RoomDTO struct {
	ID          bson.ObjectId `json:"id,omitempty" bson:"_id,omitempty"`
	Title       string        `json:"title"`
	Description string        `json:"description"`
	DateCreated time.Time     `json:"dateCreated,omitempty"`
}

RoomDTO ... default entity to structure rooms

func NewRoomDTO

func NewRoomDTO(id string, title string, description string) *RoomDTO

NewRoomDTO ... creates and returns a new room instance

type WorldDAO

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

WorldDAO ... datatype for the ruleset

func NewWorldDAO

func NewWorldDAO(db *DBAccess) *WorldDAO

NewWorldDAO ... creates a new ruleset

func (*WorldDAO) Delete

func (r *WorldDAO) Delete(world WorldDTO) error

Delete deletes a world

func (*WorldDAO) FindByID

func (r *WorldDAO) FindByID(id string) (WorldDTO, error)

FindByID ... finds a room by id

func (*WorldDAO) Insert

func (r *WorldDAO) Insert(world WorldDTO) error

Insert ... insert a room

func (*WorldDAO) Update

func (r *WorldDAO) Update(world WorldDTO) error

Update update an existing world by id

type WorldDTO

type WorldDTO struct {
	ID          bson.ObjectId `json:"id,omitempty" bson:"_id,omitempty"`
	DateCreated time.Time     `json:"dateCreated,omitempty"`
	Description string        `json:"description,omitempty"`

	Rooms          []*RoomDTO   `json:"rooms,omitempty"`
	Avatars        []*AvatarDTO `json:"avatars,omitempty"`
	StartingRoomID string       `json:"startingRoomId,omitempty"`
}

WorldDTO ... default entity to structure rooms Everything regarding content and live/dynamic data such as items, avatars, room shall be managed from the World class - all generic game/message/command related things will reside in the game class

func NewWorldDTO

func NewWorldDTO(description string) *WorldDTO

NewWorldDTO ... creates and returns a new room instance

Jump to

Keyboard shortcuts

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