common

package
v0.0.220 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 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

func Idx added in v0.0.30

func Idx() []contract.IndexEntry

func IdxSrch added in v0.0.30

func IdxSrch() []contract.SearchIndexEntry

func IdxTTL added in v0.0.54

func IdxTTL(sec int32) []contract.IndexEntry

IdxTTL returns default index entries with TTL on updated_at.

Types

type Common

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

Common defines shared fields for all documents.

func Mock added in v0.0.42

func Mock() *Common

func New added in v0.0.15

func New(m Meta, cr Core) *Common

func NewGET added in v0.0.45

func NewGET() *Common

NewGET returns a new Common object for a GET request when applying a default document.

func NewPATCH added in v0.0.17

func NewPATCH(opts NewPatchOptions) *Common

NewPATCH returns a new Common object for a PATCH request when updating an existing document.

func NewPOST added in v0.0.17

func NewPOST() *Common

NewPOST returns a new Common object for a POST request when inserting a new document.

func NewPOSTWithID added in v0.0.91

func NewPOSTWithID(x contract.ID) *Common

NewPOSTWithID returns a new Common object for a POST request when inserting a new document with a given ID.

type Commonable added in v0.0.18

type Commonable interface {
	WithCommon(x Common)
}

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