production

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

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

Go to latest
Published: Jan 19, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const Collection = "production"

Collection indicates the MongoDB production collection

Variables

This section is empty.

Functions

func Create

func Create(prod *Production) error

Create creates a new entity

func GetAll

func GetAll(opts *Options) (*model.Result, error)

GetAll returns a result based on filters

func GetByIDs

func GetByIDs(ids []string, opts *Options) (*model.Result, error)

GetByIDs returns a result by given IDs

func GetByMaterial

func GetByMaterial(id string, opts *Options) (*model.Result, error)

GetByMaterial returns a result based on material

func GetByModule

func GetByModule(id string, opts *Options) (*model.Result, error)

GetByModule returns a result based on module

func GetByOutcome

func GetByOutcome(id string, opts *Options) (*model.Result, error)

GetByOutcome returns a result based on outcome

func Remove

func Remove(id string) error

Remove removes an entity

func Replace

func Replace(id string, prod *Production) error

Replace replaces the data of an existing entity

Types

type ItemRef

type ItemRef struct {
	ID        objectID  `json:"id" bson:"id"`
	Count     uint64    `json:"count,omitempty" bson:"count,omitempty"`
	Resources uint64    `json:"resources,omitempty" bson:"resources,omitempty"`
	Kind      item.Kind `json:"kind" bson:"kind"`
}

ItemRef refers to an item and specifies its quantity

func (ItemRef) Validate

func (i ItemRef) Validate() error

Validate validates the fields of an item

type ModuleRef

type ModuleRef struct {
	ID    objectID `json:"id" bson:"id"`
	Stage uint8    `json:"stage" bson:"stage"`
}

ModuleRef refers to a module and its stage

func (ModuleRef) Validate

func (m ModuleRef) Validate() error

Validate validates the fields of a module

type Options

type Options struct {
	Sort   bson.D
	Limit  int64
	Offset int64
}

Options represents the options for a database operation

type Production

type Production struct {
	ID              objectID    `json:"_id" bson:"_id"`
	Module          objectID    `json:"module" bson:"module"`
	RequiredModules []ModuleRef `json:"requiredMods" bson:"requiredMods"`
	RequiredQuests  []Quest     `json:"requiredQuests" bson:"requiredQuests"`
	Materials       []ItemRef   `json:"materials" bson:"materials"`
	Tools           []ItemRef   `json:"tools" bson:"tools"`
	Outcome         []ItemRef   `json:"outcome" bson:"outcome"`
	Duration        int64       `json:"duration" bson:"duration"`
	Modified        timestamp   `json:"_modified" bson:"_modified"`
}

Production describes the entity of a production

func GetByID

func GetByID(id string) (*Production, error)

GetByID returns the entity of the given ID

func (Production) Validate

func (p Production) Validate() error

Validate validates the fields of a production

type Quest

type Quest struct {
	Name string `json:"name" bson:"name"`
}

Quest describes a quest requirement of a production

func (Quest) Validate

func (q Quest) Validate() error

Validate validates the fields of a quest requirement

Jump to

Keyboard shortcuts

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