e_test_base

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BestiaryModel = elemental.NewModel[Bestiary]("Bestiary", elemental.NewSchema(map[string]elemental.Field{
	"Monster": {
		Type: reflect.Struct,
		Ref:  "Monster",
	},
	"Kingdom": {
		Type: reflect.Struct,
		Ref:  "Kingdom",
	},
}, elemental.SchemaOptions{
	Collection: "bestiary",
}))
View Source
var DefaultAge = 18
View Source
var KingdomModel = elemental.NewModel[Kingdom]("Kingdom", elemental.NewSchema(map[string]elemental.Field{
	"Name": {
		Type:     reflect.String,
		Required: true,
	},
}, elemental.SchemaOptions{
	Collection: "kingdoms",
}))
View Source
var MonsterModel = elemental.NewModel[Monster]("Monster", elemental.NewSchema(map[string]elemental.Field{
	"Name": {
		Type:     reflect.String,
		Required: true,
	},
	"Category": {
		Type: reflect.String,
	},
	"Weaknesses": {
		Type: reflect.Struct,
		Schema: lo.ToPtr(elemental.NewSchema(map[string]elemental.Field{
			"Oils": {
				Type: reflect.Slice,
			},
			"Signs": {
				Type:    reflect.Slice,
				Default: []string{"Igni"},
			},
			"Decoctions": {
				Type: reflect.Slice,
			},
			"Bombs": {
				Type: reflect.Slice,
			},
			"InvulnerableTo": {
				Type:    reflect.Slice,
				Default: []string{"Steel"},
			},
		})),
	},
}, elemental.SchemaOptions{
	Collection: "monsters",
}))
View Source
var UserModel = elemental.NewModel[User]("User", elemental.NewSchema(map[string]elemental.Field{
	"Name": {
		Type:     reflect.String,
		Required: true,
		Index: options.IndexOptions{
			Unique: lo.ToPtr(true),
		},
	},
	"Age": {
		Type:    reflect.Int,
		Default: DefaultAge,
	},
	"Occupation": {
		Type: reflect.String,
	},
	"Weapons": {
		Type:    reflect.Slice,
		Default: []string{},
	},
	"Retired": {
		Type:    reflect.Bool,
		Default: false,
	},
}, elemental.SchemaOptions{
	Collection: "users",
}))

Functions

This section is empty.

Types

type Bestiary

type Bestiary struct {
	ID      primitive.ObjectID `json:"_id" bson:"_id"`
	Monster Monster            `json:"monster" bson:"monster"`
	Kingdom Kingdom            `json:"kingdom" bson:"kingdom"`
}

type Castle

type Castle struct {
	ID        primitive.ObjectID `json:"_id" bson:"_id"`
	Name      string             `json:"name" bson:"name"`
	CreatedAt time.Time          `json:"created_at" bson:"created_at"`
	UpdatedAt time.Time          `json:"updated_at" bson:"updated_at"`
}

type Kingdom

type Kingdom struct {
	ID        primitive.ObjectID `json:"_id" bson:"_id"`
	Name      string             `json:"name" bson:"name"`
	CreatedAt time.Time          `json:"created_at" bson:"created_at"`
	UpdatedAt time.Time          `json:"updated_at" bson:"updated_at"`
}

type Monster

type Monster struct {
	ID         primitive.ObjectID `json:"_id" bson:"_id"`
	Name       string             `json:"name" bson:"name"`
	Category   string             `json:"category,omitempty" bson:"category,omitempty"`
	Weaknesses MonsterWeakness    `json:"weaknesses" bson:"weaknesses"`
	CreatedAt  time.Time          `json:"created_at" bson:"created_at"`
	UpdatedAt  time.Time          `json:"updated_at" bson:"updated_at"`
}

type MonsterWeakness

type MonsterWeakness struct {
	ID             primitive.ObjectID `json:"_id" bson:"_id"`
	Oils           []string           `json:"oils" bson:"oils"`
	Signs          []string           `json:"signs" bson:"signs"`
	Decoctions     []string           `json:"decoctions" bson:"decoctions"`
	Bombs          []string           `json:"bombs" bson:"bombs"`
	InvulnerableTo []string           `json:"invulnerable_to" bson:"invulnerable_to"`
}

type User

type User struct {
	ID         primitive.ObjectID `json:"_id" bson:"_id"`
	Name       string             `json:"name" bson:"name"`
	Age        int                `json:"age" bson:"age"`
	Occupation string             `json:"occupation" bson:"occupation,omitempty"`
	Weapons    []string           `json:"weapons" bson:"weapons"`
	Retired    bool               `json:"retired" bson:"retired"`
	School     *string            `json:"school" bson:"school"`
	CreatedAt  time.Time          `json:"created_at" bson:"created_at"`
	UpdatedAt  time.Time          `json:"updated_at" bson:"updated_at"`
}

Jump to

Keyboard shortcuts

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