common

package
v0.0.29 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const (
	IDKey        = contract.IDKey
	UpdatedAtKey = "updated_at"
	CreatedAtKey = "created_at"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Common

type Common struct {
	Meta `bson:",inline" validate:"recurse"`
	Comp `bson:",inline" validate:"recurse"`
	Core `bson:",inline" validate:"recurse"`
}

Common defines shared fields for all documents.

func New added in v0.0.15

func New(m Meta, c Comp, cr Core) *Common

func NewPATCH added in v0.0.17

func NewPATCH(opts NewPatchOptions) *Common

func NewPOST added in v0.0.17

func NewPOST() *Common

type Commonable added in v0.0.18

type Commonable interface {
	WithCommon(x Common)
}

type Comp

type Comp struct{}

func ApplyComp

func ApplyComp(c *Comp, modifiers ...CompOption) Comp

type CompOption

type CompOption = contract.CompOption[Comp]

type Core

type Core struct {
	ID        *contract.ID `json:"id"`
	UpdatedAt *time.Time   `json:"updated_at" validate:"nnpt,nz"`
	CreatedAt *time.Time   `json:"created_at" validate:"nnpt,nz"`
}

func ApplyCore

func ApplyCore(c *Core, modifiers ...CoreOption) Core

func (*Core) GetCreatedAt

func (c *Core) GetCreatedAt() time.Time

func (*Core) GetID

func (c *Core) GetID() contract.ID

func (*Core) GetUpdatedAt

func (c *Core) GetUpdatedAt() time.Time

func (*Core) SetCreatedAt

func (c *Core) SetCreatedAt(x time.Time)

func (*Core) SetID

func (c *Core) SetID(x contract.ID)

func (*Core) SetUpdatedAt

func (c *Core) SetUpdatedAt(x time.Time)

type CoreOption

type CoreOption = contracti.CoreOption[Core]

func WithCreatedAt

func WithCreatedAt(x time.Time) CoreOption

func WithID

func WithID(x contract.ID) CoreOption

func WithUpdatedAt

func WithUpdatedAt(x time.Time) CoreOption

type Meta

type Meta struct{}

func ApplyMeta

func ApplyMeta(m *Meta, modifiers ...MetaOption) Meta

type MetaOption

type MetaOption = contract.MetaOption[Meta]

type NewPatchOptions added in v0.0.17

type NewPatchOptions struct {
	ID        contract.ID
	CreatedAt time.Time
}

Jump to

Keyboard shortcuts

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