store

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package store is the single-source catalog repository: one implementation against *sql.DB plus a kernel Dialect, following the comments/media store pattern. Upsert rendering and placeholder differences come from the dialect; everything else (columns, scans, messages) is shared.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is the catalog single-source store.

func New

func New(db *sql.DB, dialect kerneldatabase.Dialect) *Store

New builds the store over an open database and its dialect.

func (*Store) AdjustStock

func (s *Store) AdjustStock(ctx context.Context, contentID int, variantID *int64, delta int) (bool, error)

AdjustStock applies the signed delta to one tracked stock bucket with the condition carried in the statement itself: the row-level guard `stock + delta >= 0` makes the read-modify-write atomic, so two concurrent adjustments serialize at the row and the loser reads zero rows. Reports whether the row changed; a zero report means the bucket vanished or the move fell below zero (the service classifies).

func (*Store) GetProduct

func (s *Store) GetProduct(ctx context.Context, contentID int) (*catalogdomain.Product, error)

GetProduct returns the product with its full variant matrix, or catalogdomain.ErrProductNotFound when the content item has no row.

func (*Store) UpsertProduct

func (s *Store) UpsertProduct(ctx context.Context, contentID int, product *catalogdomain.Product) error

UpsertProduct writes the product row (insert or update via the dialect's upsert) and replaces the variant matrix wholesale, atomically.

Jump to

Keyboard shortcuts

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