universe

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UniverseResource = dsl.Resource{
		Type: dsl.SimpleResource,
		TableRef: dsl.TableRef{
			Db:         "mydb",
			Collection: "universe",
		},
		SoftDelete: true,
		ModelType:  dsl.ModelType[Universe],

		Projection: bson.M{"caption": 1, "motd": 1},
		Methods: map[string]dsl.ResourceMethod{
			"set-motd": {
				Type:    dsl.Operation,
				Handler: SetMotd,
			},
			"version": {
				Type:    dsl.View,
				Handler: GetVersion,
			},
		},
	}
)

Functions

func GetVersion

func GetVersion(
	context echo.Context, client *mongo.Client, resource, method string, collection *mongo.Collection,
	validatorMaker func() *validator.Validate, filter bson.M,
) error

GetVersion is a handler that returns the current version.

func SetMotd

func SetMotd(
	context echo.Context, client *mongo.Client, resource, method string, collection *mongo.Collection,
	validatorMaker func() *validator.Validate, filter bson.M,
) (err error)

SetMotd changes the current motd of the universe.

Types

type SetMotdBody

type SetMotdBody struct {
	Motd string `validate:"required,gt=0" json:"motd"`
}

SetMotdBody stands for the body for a "set-motd" method.

type Universe

type Universe struct {
	ID      primitive.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"`
	Caption string             `validate:"required,gt=0" bson:"caption" json:"caption"`
	Motd    string             `validate:"required,gt=0" bson:"motd" json:"motd"`
	Version UniverseVersion    `validate:"required,dive" bson:"version" json:"version"`
}

Universe is a sample singleton for the whole game layout.

type UniverseVersion

type UniverseVersion struct {
	Major    uint `bson:"major" json:"major"`
	Minor    uint `bson:"minor" json:"minor"`
	Revision uint `bson:"revision" json:"revision"`
}

UniverseVersion stands for the version of the game's universe / layout.

Jump to

Keyboard shortcuts

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