models

package
v2.0.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection struct {
	validation.ValidateStructMixin
	bun.BaseModel `bun:"table:collections"`

	ID        string    `bun:"id,pk"                                                 json:"id"`
	Name      string    `bun:"name,notnull"                                          json:"name"       validate:"required,collection_name"`
	CreatedAt time.Time `bun:"created_at,nullzero,notnull,default:current_timestamp" json:"created_at"`
	UpdatedAt time.Time `bun:"updated_at,nullzero,notnull,default:current_timestamp" json:"updated_at"`

	Items []*Item `bun:"rel:has-many,join:id=collection_id" json:"omitzero"`
}

func (*Collection) Aggregate

func (collection *Collection) Aggregate() (aggregate.Aggregate, error)

func (*Collection) BeforeAppendModel

func (collection *Collection) BeforeAppendModel(ctx context.Context, query schema.Query) error

BeforeAppendModel implements schema.BeforeAppendModelHook.

func (*Collection) MarshalJSON

func (collection *Collection) MarshalJSON() ([]byte, error)

type CollectionWithItemsCount

type CollectionWithItemsCount struct {
	Collection
	ItemsCount int `bun:"items_count"`
}

type Collections

type Collections []*CollectionWithItemsCount

type Item

type Item struct {
	validation.ValidateStructMixin
	bun.BaseModel `bun:"table:items,alias:i"`

	ID                    string    `bun:"id,pk"                                                 validate:"required,ulid"`
	Content               []byte    `bun:"content,notnull"                                       validate:"required"`
	Hash                  string    `bun:"hash,notnull"                                          validate:"required,sha256"`
	Mimetype              string    `bun:"mimetype,notnull"                                      validate:"required,mimetype"`
	LastAppliedSequenceID int64     `bun:"last_applied_sequence_id,notnull"                      validate:"gte=0"`
	CreatedAt             time.Time `bun:"created_at,nullzero,notnull,default:current_timestamp"`
	UpdatedAt             time.Time `bun:"updated_at,nullzero,notnull,default:current_timestamp"`

	CollectionID sql.NullString `bun:"collection_id"`
	Collection   *Collection    `bun:"rel:belongs-to,join:collection_id=id"`
}

func (*Item) BeforeAppendModel

func (item *Item) BeforeAppendModel(ctx context.Context, query schema.Query) error

BeforeAppendModel implements schema.BeforeAppendModelHook.

Jump to

Keyboard shortcuts

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