repository

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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyIdentifier = errs.New("identifier cannot be empty")

Functions

This section is empty.

Types

type CollectionLookupOptions

type CollectionLookupOptions struct {
	Identifier string
	Name       string
}

type CollectionRepository

type CollectionRepository interface {
	Create(ctx context.Context, tx bun.Tx, collection *models.Collection) error
	Rename(ctx context.Context, tx bun.Tx, identifier string, newName string) error
	DeleteById(ctx context.Context, tx bun.Tx, identifier string) error

	FindById(ctx context.Context, identifier string) (*models.Collection, error)
	FindByName(ctx context.Context, name string) (*models.Collection, error)
	// FindOne looks up a collection by either ID or name.
	FindOne(ctx context.Context, opts CollectionLookupOptions) (*models.Collection, error)
	FindAll(ctx context.Context, opts FindAllOptions) (models.Collections, error)
}

type FindAllOptions

type FindAllOptions struct {
	OrderBy    []OrderBy
	Pagination *Pagination
}

type ItemRepository

type ItemRepository interface {
	Create(ctx context.Context, tx bun.Tx, item *models.Item) error
	Bump(
		ctx context.Context,
		tx bun.Tx,
		identifier string,
		sequenceId int64,
	) error // Bump updates the sequence ID and updated_at timestamp of an item to move it to the top of the list.
	DeleteById(ctx context.Context, tx bun.Tx, identifier string) error

	FindLatest(ctx context.Context, collectionID string) (*models.Item, error)
	FindById(ctx context.Context, identifier string, collectionId string) (*models.Item, error)
	FindByHash(ctx context.Context, hash string, collectionId string) (*models.Item, error)
}

type OrderBy

type OrderBy struct {
	Field     string
	Ascending bool
}

type Pagination

type Pagination struct {
	Limit  int
	Offset int
}

type Repository

type Repository interface {
	Items() ItemRepository
	Collections() CollectionRepository
}

Repository is the main interface for accessing all repositories. Some methods might require a transaction (bun.Tx) to be passed in if they modify data.

func NewRepository

func NewRepository(db *bun.DB) Repository

Jump to

Keyboard shortcuts

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