shopstore

package module
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

README

Shop Store

Tests Status Go Report Card PkgGoDev

Shop Store is a Go package that provides a database-backed store for common commerce entities such as products, orders, discounts, media, and categories. It builds on the dataobject pattern to give you rich domain objects with change tracking, metadata handling, soft deletion, and query builders out of the box.

Table of contents

  1. Features
  2. Installation
  3. Quick start
  4. Product variants
  5. Domain entities
  6. Query builders
  7. Metadata & soft deletion
  8. Debugging & observability
  9. Testing
  10. Development
  11. License

Features

  • Composable store – instantiate a Store with your own table names, database connection, and migration settings.
  • Rich domain objectsCategory, Discount, Media, Order, OrderLineItem, and Product types expose defaults, helpers, predicates, and getter/setter chains.
  • Product variants – support for both simple products and parent/child product variants (e.g., size/color combinations).
  • Change tracking – entities track dirty fields and ensure updates persist only modified values.
  • Metadata support – uniform metas JSON helpers (SetMetas, UpsertMetas, Meta) across all entities.
  • Soft deletion – soft-delete helpers hide records unless explicitly requested.
  • Query builders – fluent Query helpers for filtering, pagination, sorting, and counting.
  • Auto-migration – optional schema bootstrap via sb builders.
  • Observability – opt-in SQL logging and configurable timeouts.

Installation

The module path is github.com/dracory/shopstore.

go get github.com/dracory/shopstore

Quick start

package main

import (
    "context"
    "database/sql"
    _ "modernc.org/sqlite" // or your preferred driver

    "github.com/dracory/shopstore"
)

func main() {
    db, err := sql.Open("sqlite", "file:shop.db?_pragma=busy_timeout(5000)&cache=shared")
    if err != nil {
        panic(err)
    }

    store, err := shopstore.NewStore(shopstore.NewStoreOptions{
        DB:                     db,
        CategoryTableName:      "shop_category",
        DiscountTableName:      "shop_discount",
        MediaTableName:         "shop_media",
        OrderTableName:         "shop_order",
        OrderLineItemTableName: "shop_order_line_item",
        ProductTableName:       "shop_product",
        AutomigrateEnabled:     true,
        DebugEnabled:           true,
    })
    if err != nil {
        panic(err)
    }

    ctx := context.Background()

    product := shopstore.NewProduct().
        SetTitle("Cascade T-Shirt").
        SetDescription("Premium cotton tee").
        SetQuantityInt(25).
        SetPriceFloat(19.99)

    if err := store.ProductCreate(ctx, product); err != nil {
        panic(err)
    }

    list, err := store.ProductList(ctx, shopstore.NewProductQuery().
        SetStatus(shopstore.PRODUCT_STATUS_ACTIVE).
        SetLimit(10))
    if err != nil {
        panic(err)
    }

    for _, p := range list {
        println(p.ID(), p.Title(), p.PriceFloat())
    }
}

All entity constructors set sensible defaults (IDs, timestamps, status, and empty metadata). For example:

order := shopstore.NewOrder().
    SetCustomerID("customer_123").
    SetStatus(shopstore.ORDER_STATUS_PENDING)

if err := store.OrderCreate(ctx, order); err != nil {
    // handle error
}
Product variants

The store supports both simple products (single SKU) and product variants (parent/child matrix for size, color, etc.).

Simple product (no variants):

product := shopstore.NewProduct().
    SetTitle("Cascade T-Shirt").
    SetDescription("Premium cotton tee").
    SetSKU("TS-CAS-001").
    SetQuantityInt(25).
    SetPriceFloat(19.99)

if err := store.ProductCreate(ctx, product); err != nil {
    panic(err)
}

Parent product with variants (matrix for size/color):

// 1. Create parent (display-only, defines variant dimensions)
parent := shopstore.NewProduct().
    SetTitle("Nike Air Max").
    SetStatus(shopstore.PRODUCT_STATUS_ACTIVE)

// Define variant dimensions (schema)
_ = parent.SetVariantMatrixSchema(shopstore.VariantSchema{
    {Name: "color", Required: true, Options: []string{"red", "blue", "black"}},
    {Name: "size", Required: true, Options: []string{"8", "9", "10", "11"}},
})

if err := store.ProductCreate(ctx, parent); err != nil {
    panic(err)
}

// 2. Create variant (specific color/size combination)
variant := shopstore.NewProduct().
    SetTitle("Nike Air Max").
    SetParentID(parent.GetID()).  // Links to parent
    SetSKU("NAM-RED-9").
    SetPriceFloat(129.99).
    SetQuantityInt(15).
    SetStatus(shopstore.PRODUCT_STATUS_ACTIVE)

// Store variant's dimension values
_ = variant.SetVariantMatrixValues(map[string]string{"color": "red", "size": "9"})

if err := store.ProductCreate(ctx, variant); err != nil {
    panic(err)
}

// 3. List all variants for a parent
variants, err := store.ProductVariantList(ctx, parent.GetID())
if err != nil {
    panic(err)
}

for _, v := range variants {
    println(v.GetID(), v.GetSKU(), v.GetPriceFloat())
}

Querying products:

// Get all top-level products (no parent_id)
parents, err := store.ProductList(ctx, shopstore.NewProductQuery().
    SetParentID("0"))

// Get variants of a specific parent
variants, err := store.ProductList(ctx, shopstore.NewProductQuery().
    SetParentID(parentID))

// Check if product is a parent (has variant dimensions)
isParent, err := store.ProductIsParent(ctx, productID)

// Get parent of a variant
parent, err := store.ProductGetParent(ctx, variantID)

Domain entities

Each entity embeds dataobject.DataObject, enabling fluent setters and change tracking. Key helpers include:

Entity Highlights
Product IsActive, IsDraft, slug generation, price/quantity helpers, parent/child variants support.
Order Rich status predicates (awaiting shipment, refunded, etc.).
OrderLineItem Links products to orders, maintains quantity and price helpers.
Discount Code generator, amount/percent handling, start/end scheduling.
Category Parent/child relationships, active/draft state, meta helpers.
Media Sequence positioning, media type/URL helpers for assets.

Getter and setter methods mirror column names (Title(), SetTitle(string), PriceFloat(), SetPriceFloat(float64), etc.) and accept both string/typed values where appropriate.

Query builders

The New<Category|Discount|Media|Order|OrderLineItem|Product>Query helpers expose fluent filters:

  • SetID, SetIDIn, SetStatus, SetStatusIn for equality filters.
  • SetCreatedAtGte/SetCreatedAtLte for time windows.
  • SetTitleLike for partial matches.
  • SetLimit, SetOffset, SetOrderBy, SetSortDirection for pagination and sorting.
  • SetSoftDeletedIncluded(true) to include soft-deleted rows.
  • SetCountOnly(true) to build count queries.

Queries validate their input (Validate()) so you get fast feedback on missing or invalid parameters before hitting the database.

Metadata & soft deletion

Every entity stores arbitrary key/value pairs in a JSON metas column. Use:

_ = product.SetMetas(map[string]string{"color": "navy"})
_ = product.UpsertMetas(map[string]string{"size": "L"})
size := product.Meta("size")

Soft deletion is handled via the soft_deleted_at column. Standard list operations exclude soft-deleted rows unless SetSoftDeletedIncluded(true) is used. Helpers such as ProductSoftDelete and CategorySoftDelete set the column to the current timestamp.

Debugging & observability

  • Enable SQL logging with store.EnableDebug(true, slogLogger).
  • Customize store behaviour through NewStoreOptions (AutomigrateEnabled, DebugEnabled, DbDriverName, custom timeouts).
  • AutoMigrate() runs table creation statements generated through sb column builders when AutomigrateEnabled is set.

Testing

Comprehensive unit tests cover entity defaults, predicate helpers, metadata operations, and store behaviour. Run them with:

go test ./...

Development

  • Tasks are defined in Taskfile.yml for common workflows.
  • The project targets Go 1.25 (see go.mod) and uses SQLite for integration tests via modernc.org/sqlite.
  • Contributions are welcome—please open an issue or pull request with proposed changes.

License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0). You can find a copy of the license at https://www.gnu.org/licenses/agpl-3.0.en.html.

For commercial use, please use the contact page to obtain a commercial license.

Documentation

Index

Constants

View Source
const CATEGORY_STATUS_ACTIVE = "active"
View Source
const CATEGORY_STATUS_DRAFT = "draft"
View Source
const CATEGORY_STATUS_INACTIVE = "inactive"
View Source
const COLUMN_AMOUNT = "amount"
View Source
const COLUMN_CODE = "code"
View Source
const COLUMN_CREATED_AT = "created_at"
View Source
const COLUMN_CUSTOMER_ID = "customer_id"
View Source
const COLUMN_DESCRIPTION = "description"
View Source
const COLUMN_ENDS_AT = "ends_at"
View Source
const COLUMN_ENTITY_ID = "entity_id"
View Source
const COLUMN_ID = "id"
View Source
const COLUMN_MEDIA_TYPE = "media_type"
View Source
const COLUMN_MEDIA_URL = "media_url"
View Source
const COLUMN_MEMO = "memo"
View Source
const COLUMN_METAS = "metas"
View Source
const COLUMN_ORDER_ID = "order_id"
View Source
const COLUMN_PARENT_ID = "parent_id"
View Source
const COLUMN_PRICE = "price"
View Source
const COLUMN_PRODUCT_ID = "product_id"
View Source
const COLUMN_QUANTITY = "quantity"
View Source
const COLUMN_SEQUENCE = "sequence"
View Source
const COLUMN_SHORT_DESCRIPTION = "short_description"
View Source
const COLUMN_SOFT_DELETED_AT = "soft_deleted_at"
View Source
const COLUMN_STARTS_AT = "starts_at"
View Source
const COLUMN_STATUS = "status"
View Source
const COLUMN_TITLE = "title"
View Source
const COLUMN_TYPE = "type"
View Source
const COLUMN_UPDATED_AT = "updated_at"
View Source
const COLUMN_VARIANT_MATRIX_SCHEMA = "variant_matrix_schema"
View Source
const COLUMN_VARIANT_MATRIX_VALUES = "variant_matrix_values"
View Source
const DISCOUNT_DURATION_FOREVER = "forever"
View Source
const DISCOUNT_DURATION_MONTHS = "months"
View Source
const DISCOUNT_DURATION_ONCE = "once"
View Source
const DISCOUNT_STATUS_ACTIVE = "active"
View Source
const DISCOUNT_STATUS_DRAFT = "draft"
View Source
const DISCOUNT_STATUS_INACTIVE = "inactive"
View Source
const DISCOUNT_TYPE_AMOUNT = "amount"
View Source
const DISCOUNT_TYPE_PERCENT = "percent"
View Source
const MEDIA_STATUS_ACTIVE = "active"
View Source
const MEDIA_STATUS_DRAFT = "draft"
View Source
const MEDIA_STATUS_INACTIVE = "inactive"
View Source
const MEDIA_TYPE_IMAGE_JPG = "image/jpeg"
View Source
const MEDIA_TYPE_IMAGE_PNG = "image/png"
View Source
const MEDIA_TYPE_VIDEO_MP4 = "video/mp4"
View Source
const ORDER_STATUS_AWAITING_FULFILLMENT = "awaiting_fulfillment"

Customer has completed the checkout process and payment has been confirmed.

View Source
const ORDER_STATUS_AWAITING_PAYMENT = "awaiting_payment"

Customer has completed the checkout process, but payment has yet to be confirmed.

View Source
const ORDER_STATUS_AWAITING_PICKUP = "awaiting_pickup"

Order has been packaged and is awaiting customer pickup from a seller-specified location.

View Source
const ORDER_STATUS_AWAITING_SHIPMENT = "awaiting_shipment"

Order has been pulled and packaged and is awaiting collection from a shipping provider.

View Source
const ORDER_STATUS_CANCELLED = "cancelled"

Seller has cancelled an order, due to a stock inconsistency or other reasons. Cancelling an order will not refund the order.

View Source
const ORDER_STATUS_COMPLETED = "completed"

Order has been shipped/picked up, and receipt is confirmed; client has paid for their digital product, and their file(s) are available for download.

View Source
const ORDER_STATUS_DECLINED = "declined"

Seller has marked the order as declined.

View Source
const ORDER_STATUS_DISPUTED = "disputed"

Customer has initiated a dispute resolution process for the PayPal transaction that paid for the order or the seller has marked the order as a fraudulent order.

View Source
const ORDER_STATUS_MANUAL_VERIFICATION_REQUIRED = "manual_verification_required"

Order on hold while some aspect, such as tax-exempt documentation, is manually confirmed. Orders with this status must be updated manually.

View Source
const ORDER_STATUS_PARTIALLY_REFUNDED = "partially_refunded"

Seller has partially refunded the order.

View Source
const ORDER_STATUS_PARTIALLY_SHIPPED = "partially_shipped"

Only some items in the order have been shipped.

View Source
const ORDER_STATUS_PENDING = "pending"

Customer started the checkout process but did not complete it.

View Source
const ORDER_STATUS_REFUNDED = "refunded"

Seller has used the Refund action to refund the whole order. A listing of all orders with a "Refunded" status can be found under the More tab of the View Orders screen.

View Source
const ORDER_STATUS_SHIPPED = "shipped"

Order has been shipped, but receipt has not been confirmed; seller has used the Ship Items action. A listing of all orders with a "Shipped" status can be found under the More tab of the View Orders screen.

View Source
const PRODUCT_STATUS_ACTIVE = "active"
View Source
const PRODUCT_STATUS_DISABLED = "disabled"
View Source
const PRODUCT_STATUS_DRAFT = "draft"

Variables

This section is empty.

Functions

func GenerateShortID added in v1.8.0

func GenerateShortID() string

GenerateShortID generates a new shortened ID using TimestampMicro + Crockford Base32 (lowercase) Returns a 9-character lowercase ID (e.g., "86ccrtsgx") Thread-safe: Uses mutex to prevent duplicate IDs when called concurrently

func IsShortID added in v1.8.0

func IsShortID(id string) bool

IsShortID checks if an ID appears to be a shortened ID (9 or 21 chars) vs a long HumanUid ID (32 chars)

func NormalizeID added in v1.8.0

func NormalizeID(id string) string

NormalizeID normalizes an ID to lowercase for consistent lookups Handles both short (9-char, 21-char) and long (32-char) ID formats

func ShortenID added in v1.8.0

func ShortenID(id string) string

ShortenID shortens a long ID to its shortened form - 9-char IDs: Return as-is (already shortened TimestampMicro) - 32-char IDs: Shorten to 21-char using Crockford - Other lengths: Return as-is

func UnshortenID added in v1.8.0

func UnshortenID(id string) string

UnshortenID attempts to unshorten a shortened ID back to its original form Returns the original ID if it cannot be unshortened

Types

type Category

type Category struct {
	dataobject.DataObject
}

Category represents a product category in the shop store. Categories support hierarchical structures with parent-child relationships, soft deletion, metadata storage, and status management.

func (*Category) GetCreatedAt added in v1.9.0

func (category *Category) GetCreatedAt() string

GetCreatedAt returns the creation timestamp as a string.

func (*Category) GetCreatedAtCarbon added in v1.9.0

func (category *Category) GetCreatedAtCarbon() *carbon.Carbon

GetCreatedAtCarbon returns the creation timestamp as a Carbon instance.

func (*Category) GetDescription added in v1.9.0

func (category *Category) GetDescription() string

GetDescription returns the category description.

func (*Category) GetID added in v1.9.0

func (category *Category) GetID() string

GetID returns the unique identifier.

func (*Category) GetMemo added in v1.9.0

func (category *Category) GetMemo() string

GetMemo returns the internal memo.

func (*Category) GetMeta added in v1.9.0

func (category *Category) GetMeta(name string) string

GetMeta returns a specific metadata value by name. Returns empty string if not found.

func (*Category) GetMetas added in v1.9.0

func (category *Category) GetMetas() (map[string]string, error)

GetMetas returns all metadata as a map. Returns empty map if no metas stored.

func (*Category) GetParentID added in v1.9.0

func (category *Category) GetParentID() string

GetParentID returns the parent category ID (empty if root category).

func (*Category) GetSoftDeletedAt added in v1.9.0

func (category *Category) GetSoftDeletedAt() string

GetSoftDeletedAt returns the soft deletion timestamp.

func (*Category) GetSoftDeletedAtCarbon added in v1.9.0

func (category *Category) GetSoftDeletedAtCarbon() *carbon.Carbon

GetSoftDeletedAtCarbon returns the soft deletion timestamp as a Carbon instance.

func (*Category) GetStatus added in v1.9.0

func (category *Category) GetStatus() string

GetStatus returns the current status.

func (*Category) GetTitle added in v1.9.0

func (category *Category) GetTitle() string

GetTitle returns the category title.

func (*Category) GetUpdatedAt added in v1.9.0

func (category *Category) GetUpdatedAt() string

GetUpdatedAt returns the last update timestamp.

func (*Category) GetUpdatedAtCarbon added in v1.9.0

func (category *Category) GetUpdatedAtCarbon() *carbon.Carbon

GetUpdatedAtCarbon returns the last update timestamp as a Carbon instance.

func (*Category) IsActive

func (category *Category) IsActive() bool

IsActive returns true if the category status is active.

func (*Category) IsChild added in v1.9.0

func (category *Category) IsChild() bool

IsChild returns true if the category has a parent (parent_id is not empty)

func (*Category) IsDraft

func (category *Category) IsDraft() bool

IsDraft returns true if the category status is draft.

func (*Category) IsInactive

func (category *Category) IsInactive() bool

IsInactive returns true if the category status is inactive.

func (*Category) IsRoot added in v1.9.0

func (category *Category) IsRoot() bool

IsRoot returns true if the category has no parent (parent_id is empty)

func (*Category) IsSoftDeleted

func (category *Category) IsSoftDeleted() bool

IsSoftDeleted returns true if the category is soft deleted.

func (*Category) MetaRemove added in v1.9.0

func (category *Category) MetaRemove(name string) error

MetaRemove removes a single metadata entry.

func (*Category) MetasRemove added in v1.9.0

func (category *Category) MetasRemove(names []string) error

MetasRemove removes multiple metadata entries.

func (*Category) MetasUpsert added in v1.9.0

func (category *Category) MetasUpsert(metas map[string]string) error

MetasUpsert merges the provided metadata with existing values.

func (*Category) SetCreatedAt

func (category *Category) SetCreatedAt(createdAt string) CategoryInterface

SetCreatedAt sets the creation timestamp.

func (*Category) SetDescription

func (category *Category) SetDescription(description string) CategoryInterface

SetDescription sets the category description.

func (*Category) SetID

func (category *Category) SetID(id string) CategoryInterface

SetID sets the unique identifier.

func (*Category) SetMemo

func (category *Category) SetMemo(memo string) CategoryInterface

SetMemo sets the internal memo.

func (*Category) SetMeta

func (category *Category) SetMeta(name string, value string) error

SetMeta sets a single metadata value.

func (*Category) SetMetas

func (category *Category) SetMetas(metas map[string]string) error

SetMetas replaces all metadata with the provided map. Warning: this overwrites any existing metadata.

func (*Category) SetParentID

func (category *Category) SetParentID(parentID string) CategoryInterface

SetParentID sets the parent category ID. Empty string makes it a root category.

func (*Category) SetSoftDeletedAt

func (category *Category) SetSoftDeletedAt(softDeletedAt string) CategoryInterface

SetSoftDeletedAt sets the soft deletion timestamp.

func (*Category) SetStatus

func (category *Category) SetStatus(status string) CategoryInterface

SetStatus sets the current status.

func (*Category) SetTitle

func (category *Category) SetTitle(title string) CategoryInterface

SetTitle sets the category title.

func (*Category) SetUpdatedAt

func (category *Category) SetUpdatedAt(updatedAt string) CategoryInterface

SetUpdatedAt sets the last update timestamp.

type CategoryInterface

type CategoryInterface interface {

	// Data returns a map of all field values for serialization.
	Data() map[string]string
	// DataChanged returns a map of only the fields that have been modified since load.
	DataChanged() map[string]string
	// MarkAsNotDirty resets the dirty state, clearing all change tracking.
	MarkAsNotDirty()

	// GetCreatedAt returns the creation timestamp as a string.
	GetCreatedAt() string
	// GetCreatedAtCarbon returns the creation timestamp as a Carbon instance.
	GetCreatedAtCarbon() *carbon.Carbon
	// SetCreatedAt sets the creation timestamp.
	SetCreatedAt(createdAt string) CategoryInterface

	// GetDescription returns the category description.
	GetDescription() string
	// SetDescription sets the category description.
	SetDescription(description string) CategoryInterface

	// GetID returns the unique identifier.
	GetID() string
	// SetID sets the unique identifier.
	SetID(id string) CategoryInterface

	// GetMemo returns the internal memo.
	GetMemo() string
	// SetMemo sets the internal memo.
	SetMemo(memo string) CategoryInterface

	// GetMetas returns all metadata as a map.
	GetMetas() (map[string]string, error)
	// GetMeta returns a specific metadata value by name.
	GetMeta(name string) string
	// SetMeta sets a single metadata value.
	SetMeta(name string, value string) error
	// SetMetas replaces all metadata with the provided map.
	SetMetas(metas map[string]string) error
	// MetasUpsert merges the provided metadata with existing values.
	MetasUpsert(metas map[string]string) error
	// MetaRemove removes a single metadata entry.
	MetaRemove(name string) error
	// MetasRemove removes multiple metadata entries.
	MetasRemove(names []string) error

	// GetParentID returns the parent category ID (empty if root).
	GetParentID() string
	// SetParentID sets the parent category ID.
	SetParentID(parentID string) CategoryInterface

	// GetStatus returns the current status.
	GetStatus() string
	// SetStatus sets the current status.
	SetStatus(status string) CategoryInterface

	// GetTitle returns the category title.
	GetTitle() string
	// SetTitle sets the category title.
	SetTitle(title string) CategoryInterface

	// GetSoftDeletedAt returns the soft deletion timestamp.
	GetSoftDeletedAt() string
	// GetSoftDeletedAtCarbon returns the soft deletion timestamp as a Carbon instance.
	GetSoftDeletedAtCarbon() *carbon.Carbon
	// SetSoftDeletedAt sets the soft deletion timestamp.
	SetSoftDeletedAt(deletedAt string) CategoryInterface

	// GetUpdatedAt returns the last update timestamp.
	GetUpdatedAt() string
	// GetUpdatedAtCarbon returns the last update timestamp as a Carbon instance.
	GetUpdatedAtCarbon() *carbon.Carbon
	// SetUpdatedAt sets the last update timestamp.
	SetUpdatedAt(updatedAt string) CategoryInterface

	// IsActive returns true if status is active.
	IsActive() bool
	// IsDraft returns true if status is draft.
	IsDraft() bool
	// IsInactive returns true if status is inactive.
	IsInactive() bool
	// IsSoftDeleted returns true if the category is soft deleted.
	IsSoftDeleted() bool

	// IsRoot returns true if this is a root category (no parent).
	IsRoot() bool
	// IsChild returns true if this category has a parent.
	IsChild() bool
}

CategoryInterface defines the contract for category entities in the shop store. Categories support hierarchical structures (parent-child relationships), soft deletion, metadata storage, and status management.

func NewCategory

func NewCategory() CategoryInterface

NewCategory creates a new category with default values: - Status: draft - ParentID: empty (root category) - Description: empty - Memo: empty - CreatedAt: current UTC time - UpdatedAt: current UTC time - SoftDeletedAt: max datetime (not deleted) - Metas: empty map

func NewCategoryFromExistingData

func NewCategoryFromExistingData(data map[string]string) CategoryInterface

NewCategoryFromExistingData creates a category from existing data map. Used when hydrating from database or external sources.

type CategoryQueryInterface

type CategoryQueryInterface interface {
	Validate() error

	Columns() []string
	SetColumns(columns []string) CategoryQueryInterface

	HasCountOnly() bool
	IsCountOnly() bool
	SetCountOnly(countOnly bool) CategoryQueryInterface

	HasID() bool
	ID() string
	SetID(id string) CategoryQueryInterface

	HasIDIn() bool
	IDIn() []string
	SetIDIn(idIn []string) CategoryQueryInterface

	HasLimit() bool
	Limit() int
	SetLimit(limit int) CategoryQueryInterface

	HasOffset() bool
	Offset() int
	SetOffset(offset int) CategoryQueryInterface

	HasOrderBy() bool
	OrderBy() string
	SetOrderBy(orderBy string) CategoryQueryInterface

	HasSortDirection() bool
	SortDirection() string
	SetSortDirection(sortDirection string) CategoryQueryInterface

	HasParentID() bool
	ParentID() string
	SetParentID(parentID string) CategoryQueryInterface

	HasSoftDeletedIncluded() bool
	SoftDeletedIncluded() bool
	SetSoftDeletedIncluded(softDeletedIncluded bool) CategoryQueryInterface

	HasStatus() bool
	Status() string
	SetStatus(status string) CategoryQueryInterface

	HasTitleLike() bool
	TitleLike() string
	SetTitleLike(titleLike string) CategoryQueryInterface
	// contains filtered or unexported methods
}

func NewCategoryQuery

func NewCategoryQuery() CategoryQueryInterface

type Discount

type Discount struct {
	dataobject.DataObject
}

Discount represents a discount/promotion in the shop store. Discounts support temporal validity (start/end dates), amount-based discounts, soft deletion, metadata storage, and status management.

func (*Discount) GetAmount added in v1.9.0

func (d *Discount) GetAmount() float64

GetAmount returns the discount amount as a float64.

func (*Discount) GetCode added in v1.9.0

func (d *Discount) GetCode() string

GetCode returns the unique discount code.

func (*Discount) GetCreatedAt added in v1.9.0

func (d *Discount) GetCreatedAt() string

GetCreatedAt returns the creation timestamp as a string.

func (*Discount) GetCreatedAtCarbon added in v1.9.0

func (d *Discount) GetCreatedAtCarbon() *carbon.Carbon

GetCreatedAtCarbon returns the creation timestamp as a Carbon instance.

func (*Discount) GetDescription added in v1.9.0

func (d *Discount) GetDescription() string

GetDescription returns the discount description.

func (*Discount) GetEndsAt added in v1.9.0

func (d *Discount) GetEndsAt() string

GetEndsAt returns the end date/time as a string.

func (*Discount) GetEndsAtCarbon added in v1.9.0

func (d *Discount) GetEndsAtCarbon() *carbon.Carbon

GetEndsAtCarbon returns the end date/time as a Carbon instance.

func (*Discount) GetID added in v1.9.0

func (d *Discount) GetID() string

GetID returns the unique identifier.

func (*Discount) GetMemo added in v1.9.0

func (d *Discount) GetMemo() string

GetMemo returns the internal memo.

func (*Discount) GetMeta added in v1.9.0

func (d *Discount) GetMeta(name string) string

GetMeta returns a specific metadata value by name. Returns empty string if not found.

func (*Discount) GetMetas added in v1.9.0

func (d *Discount) GetMetas() (map[string]string, error)

GetMetas returns all metadata as a map. Returns empty map if no metas stored.

func (*Discount) GetSoftDeletedAt added in v1.9.0

func (d *Discount) GetSoftDeletedAt() string

GetSoftDeletedAt returns the soft deletion timestamp.

func (*Discount) GetSoftDeletedAtCarbon added in v1.9.0

func (d *Discount) GetSoftDeletedAtCarbon() *carbon.Carbon

GetSoftDeletedAtCarbon returns the soft deletion timestamp as a Carbon instance.

func (*Discount) GetStartsAt added in v1.9.0

func (d *Discount) GetStartsAt() string

GetStartsAt returns the start date/time as a string.

func (*Discount) GetStartsAtCarbon added in v1.9.0

func (d *Discount) GetStartsAtCarbon() *carbon.Carbon

GetStartsAtCarbon returns the start date/time as a Carbon instance.

func (*Discount) GetStatus added in v1.9.0

func (d *Discount) GetStatus() string

GetStatus returns the current status.

func (*Discount) GetTitle added in v1.9.0

func (d *Discount) GetTitle() string

GetTitle returns the discount title.

func (*Discount) GetType added in v1.9.0

func (d *Discount) GetType() string

GetType returns the discount type (amount or percent).

func (*Discount) GetUpdatedAt added in v1.9.0

func (d *Discount) GetUpdatedAt() string

GetUpdatedAt returns the last update timestamp.

func (*Discount) GetUpdatedAtCarbon added in v1.9.0

func (d *Discount) GetUpdatedAtCarbon() *carbon.Carbon

GetUpdatedAtCarbon returns the last update timestamp as a Carbon instance.

func (*Discount) IsActive added in v1.9.0

func (d *Discount) IsActive() bool

IsActive returns true if the discount status is active.

func (*Discount) IsDraft added in v1.9.0

func (d *Discount) IsDraft() bool

IsDraft returns true if the discount status is draft.

func (*Discount) IsEnded added in v1.9.0

func (d *Discount) IsEnded() bool

IsEnded returns true if the discount period has ended (ends_at <= now).

func (*Discount) IsExpired added in v1.9.0

func (d *Discount) IsExpired() bool

IsExpired is an alias for IsEnded.

func (*Discount) IsInactive added in v1.9.0

func (d *Discount) IsInactive() bool

IsInactive returns true if the discount status is inactive.

func (*Discount) IsStarted added in v1.9.0

func (d *Discount) IsStarted() bool

IsStarted returns true if the discount period has started (starts_at <= now).

func (*Discount) IsValidNow added in v1.9.0

func (d *Discount) IsValidNow() bool

IsValidNow returns true if the discount is active, started, and not ended.

func (*Discount) MetaRemove

func (d *Discount) MetaRemove(name string) error

MetaRemove removes a single metadata entry.

func (*Discount) MetasRemove

func (d *Discount) MetasRemove(names []string) error

MetasRemove removes multiple metadata entries.

func (*Discount) MetasUpsert

func (d *Discount) MetasUpsert(metas map[string]string) error

MetasUpsert merges the provided metadata with existing values.

func (*Discount) SetAmount

func (d *Discount) SetAmount(amount float64) DiscountInterface

SetAmount sets the discount amount.

func (*Discount) SetCode

func (d *Discount) SetCode(code string) DiscountInterface

SetCode sets the unique discount code.

func (*Discount) SetCreatedAt

func (d *Discount) SetCreatedAt(createdAt string) DiscountInterface

SetCreatedAt sets the creation timestamp.

func (*Discount) SetDescription

func (d *Discount) SetDescription(description string) DiscountInterface

SetDescription sets the discount description.

func (*Discount) SetEndsAt

func (d *Discount) SetEndsAt(endsAt string) DiscountInterface

SetEndsAt sets the end date/time.

func (*Discount) SetID

func (d *Discount) SetID(id string) DiscountInterface

SetID sets the unique identifier.

func (*Discount) SetMemo

func (d *Discount) SetMemo(memo string) DiscountInterface

SetMemo sets the internal memo.

func (*Discount) SetMeta

func (d *Discount) SetMeta(name string, value string) error

SetMeta sets a single metadata value.

func (*Discount) SetMetas

func (d *Discount) SetMetas(metas map[string]string) error

SetMetas replaces all metadata with the provided map. Warning: this overwrites any existing metadata.

func (*Discount) SetSoftDeletedAt

func (d *Discount) SetSoftDeletedAt(deletedAt string) DiscountInterface

SetSoftDeletedAt sets the soft deletion timestamp.

func (*Discount) SetStartsAt

func (d *Discount) SetStartsAt(startsAt string) DiscountInterface

SetStartsAt sets the start date/time.

func (*Discount) SetStatus

func (d *Discount) SetStatus(status string) DiscountInterface

SetStatus sets the current status.

func (*Discount) SetTitle

func (d *Discount) SetTitle(title string) DiscountInterface

SetTitle sets the discount title.

func (*Discount) SetType

func (d *Discount) SetType(type_ string) DiscountInterface

SetType sets the discount type.

func (*Discount) SetUpdatedAt

func (d *Discount) SetUpdatedAt(updatedAt string) DiscountInterface

SetUpdatedAt sets the last update timestamp.

type DiscountInterface

type DiscountInterface interface {

	// Data returns a map of all field values for serialization.
	Data() map[string]string
	// DataChanged returns a map of only the fields that have been modified since load.
	DataChanged() map[string]string
	// MarkAsNotDirty resets the dirty state, clearing all change tracking.
	MarkAsNotDirty()

	// GetAmount returns the discount amount.
	GetAmount() float64
	// SetAmount sets the discount amount.
	SetAmount(amount float64) DiscountInterface

	// GetCode returns the unique discount code.
	GetCode() string
	// SetCode sets the unique discount code.
	SetCode(code string) DiscountInterface

	// GetCreatedAt returns the creation timestamp as a string.
	GetCreatedAt() string
	// GetCreatedAtCarbon returns the creation timestamp as a Carbon instance.
	GetCreatedAtCarbon() *carbon.Carbon
	// SetCreatedAt sets the creation timestamp.
	SetCreatedAt(createdAt string) DiscountInterface

	// GetDescription returns the discount description.
	GetDescription() string
	// SetDescription sets the discount description.
	SetDescription(description string) DiscountInterface

	// GetEndsAt returns the end date/time as a string.
	GetEndsAt() string
	// GetEndsAtCarbon returns the end date/time as a Carbon instance.
	GetEndsAtCarbon() *carbon.Carbon
	// SetEndsAt sets the end date/time.
	SetEndsAt(endsAt string) DiscountInterface

	// GetID returns the unique identifier.
	GetID() string
	// SetID sets the unique identifier.
	SetID(id string) DiscountInterface

	// GetMemo returns the internal memo.
	GetMemo() string
	// SetMemo sets the internal memo.
	SetMemo(memo string) DiscountInterface

	// GetMeta returns a specific metadata value by name.
	GetMeta(name string) string
	// GetMetas returns all metadata as a map.
	GetMetas() (map[string]string, error)
	// SetMeta sets a single metadata value.
	SetMeta(name string, value string) error
	// SetMetas replaces all metadata with the provided map.
	SetMetas(metas map[string]string) error
	// MetasUpsert merges the provided metadata with existing values.
	MetasUpsert(metas map[string]string) error
	// MetaRemove removes a single metadata entry.
	MetaRemove(name string) error
	// MetasRemove removes multiple metadata entries.
	MetasRemove(names []string) error

	// GetSoftDeletedAt returns the soft deletion timestamp.
	GetSoftDeletedAt() string
	// GetSoftDeletedAtCarbon returns the soft deletion timestamp as a Carbon instance.
	GetSoftDeletedAtCarbon() *carbon.Carbon
	// SetSoftDeletedAt sets the soft deletion timestamp.
	SetSoftDeletedAt(deletedAt string) DiscountInterface

	// GetStartsAt returns the start date/time as a string.
	GetStartsAt() string
	// GetStartsAtCarbon returns the start date/time as a Carbon instance.
	GetStartsAtCarbon() *carbon.Carbon
	// SetStartsAt sets the start date/time.
	SetStartsAt(startsAt string) DiscountInterface

	// GetStatus returns the current status.
	GetStatus() string
	// SetStatus sets the current status.
	SetStatus(status string) DiscountInterface

	// GetTitle returns the discount title.
	GetTitle() string
	// SetTitle sets the discount title.
	SetTitle(title string) DiscountInterface

	// GetType returns the discount type.
	GetType() string
	// SetType sets the discount type.
	SetType(type_ string) DiscountInterface

	// GetUpdatedAt returns the last update timestamp.
	GetUpdatedAt() string
	// GetUpdatedAtCarbon returns the last update timestamp as a Carbon instance.
	GetUpdatedAtCarbon() *carbon.Carbon
	// SetUpdatedAt sets the last update timestamp.
	SetUpdatedAt(updatedAt string) DiscountInterface

	// IsActive returns true if status is active.
	IsActive() bool
	// IsDraft returns true if status is draft.
	IsDraft() bool
	// IsInactive returns true if status is inactive.
	IsInactive() bool

	// IsStarted returns true if the discount period has started.
	IsStarted() bool
	// IsEnded returns true if the discount period has ended.
	IsEnded() bool
	// IsExpired returns true if the discount is no longer valid.
	IsExpired() bool
	// IsValidNow returns true if the discount is currently valid (started and not ended).
	IsValidNow() bool
}

DiscountInterface defines the contract for discount/promotion entities. Discounts support temporal validity (start/end dates), amount-based discounts, soft deletion, metadata storage, and status management.

func NewDiscount

func NewDiscount() DiscountInterface

NewDiscount creates a new discount with default values: - Status: draft - Type: percent - Amount: 0.00 - Code: randomly generated 12-character code - Title: empty - Description: empty - StartsAt: null datetime - EndsAt: null datetime - Memo: empty - CreatedAt: current UTC time - UpdatedAt: current UTC time - SoftDeletedAt: max datetime (not deleted) - Metas: empty map

func NewDiscountFromExistingData

func NewDiscountFromExistingData(data map[string]string) DiscountInterface

NewDiscountFromExistingData creates a discount from existing data map. Used when hydrating from database or external sources.

type DiscountQueryInterface

type DiscountQueryInterface interface {
	Validate() error

	Columns() []string
	SetColumns(columns []string) DiscountQueryInterface

	HasCountOnly() bool
	IsCountOnly() bool
	SetCountOnly(countOnly bool) DiscountQueryInterface

	HasCreatedAtGte() bool
	CreatedAtGte() string
	SetCreatedAtGte(createdAtGte string) DiscountQueryInterface

	HasCreatedAtLte() bool
	CreatedAtLte() string
	SetCreatedAtLte(createdAtLte string) DiscountQueryInterface

	HasCode() bool
	Code() string
	SetCode(code string) DiscountQueryInterface

	HasEndsAtGte() bool
	EndsAtGte() string
	SetEndsAtGte(endsAtGte string) DiscountQueryInterface

	HasEndsAtLte() bool
	EndsAtLte() string
	SetEndsAtLte(endsAtLte string) DiscountQueryInterface

	HasID() bool
	ID() string
	SetID(id string) DiscountQueryInterface

	HasIDIn() bool
	IDIn() []string
	SetIDIn(idIn []string) DiscountQueryInterface

	HasLimit() bool
	Limit() int
	SetLimit(limit int) DiscountQueryInterface

	HasOffset() bool
	Offset() int
	SetOffset(offset int) DiscountQueryInterface

	HasOrderBy() bool
	OrderBy() string
	SetOrderBy(discountBy string) DiscountQueryInterface

	HasSortDirection() bool
	SortDirection() string
	SetSortDirection(sortDirection string) DiscountQueryInterface

	HasSoftDeletedIncluded() bool
	SoftDeletedIncluded() bool
	SetSoftDeletedIncluded(softDeletedIncluded bool) DiscountQueryInterface

	HasStartsAtGte() bool
	StartsAtGte() string
	SetStartsAtGte(startsAtGte string) DiscountQueryInterface

	HasStartsAtLte() bool
	StartsAtLte() string
	SetStartsAtLte(startsAtLte string) DiscountQueryInterface

	HasStatus() bool
	Status() string
	SetStatus(status string) DiscountQueryInterface

	HasStatusIn() bool
	StatusIn() []string
	SetStatusIn(statusIn []string) DiscountQueryInterface

	HasType() bool
	Type() string
	SetType(discountType string) DiscountQueryInterface
	// contains filtered or unexported methods
}

func NewDiscountQuery

func NewDiscountQuery() DiscountQueryInterface

type Media

type Media struct {
	dataobject.DataObject
}

Media represents a media file (image, video, etc) in the shop store. Media files are associated with entities via EntityID, support sequencing for ordering, soft deletion, metadata storage, and type classification.

func (*Media) GetCreatedAt added in v1.9.0

func (m *Media) GetCreatedAt() string

GetCreatedAt returns the creation timestamp as a string.

func (*Media) GetCreatedAtCarbon added in v1.9.0

func (m *Media) GetCreatedAtCarbon() *carbon.Carbon

GetCreatedAtCarbon returns the creation timestamp as a Carbon instance.

func (*Media) GetDescription added in v1.9.0

func (m *Media) GetDescription() string

GetDescription returns the media description.

func (*Media) GetEntityID added in v1.9.0

func (m *Media) GetEntityID() string

GetEntityID returns the associated entity ID.

func (*Media) GetID added in v1.9.0

func (m *Media) GetID() string

GetID returns the unique identifier.

func (*Media) GetMemo added in v1.9.0

func (m *Media) GetMemo() string

GetMemo returns the internal memo.

func (*Media) GetMeta added in v1.9.0

func (m *Media) GetMeta(name string) string

GetMeta returns a specific metadata value by name. Returns empty string if not found.

func (*Media) GetMetas added in v1.9.0

func (m *Media) GetMetas() (map[string]string, error)

GetMetas returns all metadata as a map. Returns empty map if no metas stored.

func (*Media) GetSequence added in v1.9.0

func (m *Media) GetSequence() int

GetSequence returns the display sequence/order.

func (*Media) GetSoftDeletedAt added in v1.9.0

func (m *Media) GetSoftDeletedAt() string

GetSoftDeletedAt returns the soft deletion timestamp.

func (*Media) GetSoftDeletedAtCarbon added in v1.9.0

func (m *Media) GetSoftDeletedAtCarbon() *carbon.Carbon

GetSoftDeletedAtCarbon returns the soft deletion timestamp as a Carbon instance.

func (*Media) GetStatus added in v1.9.0

func (m *Media) GetStatus() string

GetStatus returns the current status.

func (*Media) GetTitle added in v1.9.0

func (m *Media) GetTitle() string

GetTitle returns the media title.

func (*Media) GetType added in v1.9.0

func (m *Media) GetType() string

GetType returns the media type (e.g., image/jpeg, video/mp4).

func (*Media) GetURL added in v1.9.0

func (m *Media) GetURL() string

GetURL returns the media file URL.

func (*Media) GetUpdatedAt added in v1.9.0

func (m *Media) GetUpdatedAt() string

GetUpdatedAt returns the last update timestamp.

func (*Media) GetUpdatedAtCarbon added in v1.9.0

func (m *Media) GetUpdatedAtCarbon() *carbon.Carbon

GetUpdatedAtCarbon returns the last update timestamp as a Carbon instance.

func (*Media) IsActive added in v1.9.0

func (m *Media) IsActive() bool

IsActive returns true if the media status is active.

func (*Media) IsDraft added in v1.9.0

func (m *Media) IsDraft() bool

IsDraft returns true if the media status is draft.

func (*Media) IsImage added in v1.9.0

func (m *Media) IsImage() bool

IsImage returns true if the media type starts with "image/".

func (*Media) IsInactive added in v1.9.0

func (m *Media) IsInactive() bool

IsInactive returns true if the media status is inactive.

func (*Media) IsSoftDeleted added in v1.9.0

func (m *Media) IsSoftDeleted() bool

IsSoftDeleted returns true if the media is soft deleted.

func (*Media) IsVideo added in v1.9.0

func (m *Media) IsVideo() bool

IsVideo returns true if the media type starts with "video/".

func (*Media) MetaRemove added in v1.9.0

func (m *Media) MetaRemove(name string) error

MetaRemove removes a single metadata entry.

func (*Media) MetasRemove added in v1.9.0

func (m *Media) MetasRemove(names []string) error

MetasRemove removes multiple metadata entries.

func (*Media) MetasUpsert added in v1.9.0

func (m *Media) MetasUpsert(metas map[string]string) error

MetasUpsert merges the provided metadata with existing values.

func (*Media) SetCreatedAt

func (m *Media) SetCreatedAt(createdAt string) MediaInterface

SetCreatedAt sets the creation timestamp.

func (*Media) SetDescription

func (m *Media) SetDescription(description string) MediaInterface

SetDescription sets the media description.

func (*Media) SetEntityID

func (m *Media) SetEntityID(entityID string) MediaInterface

SetEntityID sets the associated entity ID.

func (*Media) SetID

func (m *Media) SetID(id string) MediaInterface

SetID sets the unique identifier.

func (*Media) SetMemo

func (m *Media) SetMemo(memo string) MediaInterface

SetMemo sets the internal memo.

func (*Media) SetMeta

func (m *Media) SetMeta(name string, value string) error

SetMeta sets a single metadata value.

func (*Media) SetMetas

func (m *Media) SetMetas(metas map[string]string) error

SetMetas replaces all metadata with the provided map. Warning: this overwrites any existing metadata.

func (*Media) SetSequence

func (m *Media) SetSequence(sequence int) MediaInterface

SetSequence sets the display sequence/order.

func (*Media) SetSoftDeletedAt

func (m *Media) SetSoftDeletedAt(softDeletedAt string) MediaInterface

SetSoftDeletedAt sets the soft deletion timestamp.

func (*Media) SetStatus

func (m *Media) SetStatus(status string) MediaInterface

SetStatus sets the current status.

func (*Media) SetTitle

func (m *Media) SetTitle(title string) MediaInterface

SetTitle sets the media title.

func (*Media) SetType

func (m *Media) SetType(type_ string) MediaInterface

SetType sets the media type.

func (*Media) SetURL

func (m *Media) SetURL(url string) MediaInterface

SetURL sets the media file URL.

func (*Media) SetUpdatedAt

func (m *Media) SetUpdatedAt(updatedAt string) MediaInterface

SetUpdatedAt sets the last update timestamp.

type MediaInterface

type MediaInterface interface {

	// Data returns a map of all field values for serialization.
	Data() map[string]string
	// DataChanged returns a map of only the fields that have been modified since load.
	DataChanged() map[string]string
	// MarkAsNotDirty resets the dirty state, clearing all change tracking.
	MarkAsNotDirty()

	// GetCreatedAt returns the creation timestamp as a string.
	GetCreatedAt() string
	// GetCreatedAtCarbon returns the creation timestamp as a Carbon instance.
	GetCreatedAtCarbon() *carbon.Carbon
	// SetCreatedAt sets the creation timestamp.
	SetCreatedAt(createdAt string) MediaInterface

	// GetDescription returns the media description.
	GetDescription() string
	// SetDescription sets the media description.
	SetDescription(description string) MediaInterface

	// GetEntityID returns the associated entity ID.
	GetEntityID() string
	// SetEntityID sets the associated entity ID.
	SetEntityID(entityID string) MediaInterface

	// GetID returns the unique identifier.
	GetID() string
	// SetID sets the unique identifier.
	SetID(id string) MediaInterface

	// GetMemo returns the internal memo.
	GetMemo() string
	// SetMemo sets the internal memo.
	SetMemo(memo string) MediaInterface

	// GetMetas returns all metadata as a map.
	GetMetas() (map[string]string, error)
	// GetMeta returns a specific metadata value by name.
	GetMeta(name string) string
	// SetMeta sets a single metadata value.
	SetMeta(name string, value string) error
	// SetMetas replaces all metadata with the provided map.
	SetMetas(metas map[string]string) error
	// MetasUpsert merges the provided metadata with existing values.
	MetasUpsert(metas map[string]string) error
	// MetaRemove removes a single metadata entry.
	MetaRemove(name string) error
	// MetasRemove removes multiple metadata entries.
	MetasRemove(names []string) error

	// GetSequence returns the display sequence/order.
	GetSequence() int
	// SetSequence sets the display sequence/order.
	SetSequence(sequence int) MediaInterface

	// GetSoftDeletedAt returns the soft deletion timestamp.
	GetSoftDeletedAt() string
	// GetSoftDeletedAtCarbon returns the soft deletion timestamp as a Carbon instance.
	GetSoftDeletedAtCarbon() *carbon.Carbon
	// SetSoftDeletedAt sets the soft deletion timestamp.
	SetSoftDeletedAt(softDeletedAt string) MediaInterface

	// GetStatus returns the current status.
	GetStatus() string
	// SetStatus sets the current status.
	SetStatus(status string) MediaInterface

	// GetTitle returns the media title.
	GetTitle() string
	// SetTitle sets the media title.
	SetTitle(title string) MediaInterface

	// GetType returns the media type (image, video, etc).
	GetType() string
	// SetType sets the media type.
	SetType(mediaType string) MediaInterface

	// GetURL returns the media file URL.
	GetURL() string
	// SetURL sets the media file URL.
	SetURL(url string) MediaInterface

	// GetUpdatedAt returns the last update timestamp.
	GetUpdatedAt() string
	// GetUpdatedAtCarbon returns the last update timestamp as a Carbon instance.
	GetUpdatedAtCarbon() *carbon.Carbon
	// SetUpdatedAt sets the last update timestamp.
	SetUpdatedAt(updatedAt string) MediaInterface

	// IsActive returns true if status is active.
	IsActive() bool
	// IsDraft returns true if status is draft.
	IsDraft() bool
	// IsInactive returns true if status is inactive.
	IsInactive() bool
	// IsSoftDeleted returns true if the media is soft deleted.
	IsSoftDeleted() bool

	// IsImage returns true if media type is image.
	IsImage() bool
	// IsVideo returns true if media type is video.
	IsVideo() bool
}

MediaInterface defines the contract for media entities (images, videos, etc). Media files are associated with entities via EntityID, support sequencing for ordering, soft deletion, metadata storage, and type classification.

func NewMedia

func NewMedia() MediaInterface

NewMedia creates a new media entity with default values: - Status: draft - Title: empty - Description: empty - Memo: empty - CreatedAt: current UTC time - UpdatedAt: current UTC time - SoftDeletedAt: max datetime (not deleted) - Metas: empty map

func NewMediaFromExistingData

func NewMediaFromExistingData(data map[string]string) MediaInterface

NewMediaFromExistingData creates a media entity from existing data map. Used when hydrating from database or external sources.

type MediaQueryInterface

type MediaQueryInterface interface {
	Validate() error

	Columns() []string
	SetColumns(columns []string) MediaQueryInterface

	HasCountOnly() bool
	IsCountOnly() bool
	SetCountOnly(countOnly bool) MediaQueryInterface

	HasEntityID() bool
	EntityID() string
	SetEntityID(entityID string) MediaQueryInterface

	HasID() bool
	ID() string
	SetID(id string) MediaQueryInterface

	HasIDIn() bool
	IDIn() []string
	SetIDIn(idIn []string) MediaQueryInterface

	HasLimit() bool
	Limit() int
	SetLimit(limit int) MediaQueryInterface

	HasOffset() bool
	Offset() int
	SetOffset(offset int) MediaQueryInterface

	HasOrderBy() bool
	OrderBy() string
	SetOrderBy(orderBy string) MediaQueryInterface

	HasSortDirection() bool
	SortDirection() string
	SetSortDirection(sortDirection string) MediaQueryInterface

	HasSoftDeletedIncluded() bool
	SoftDeletedIncluded() bool
	SetSoftDeletedIncluded(softDeletedIncluded bool) MediaQueryInterface

	HasStatus() bool
	Status() string
	SetStatus(status string) MediaQueryInterface

	HasTitleLike() bool
	TitleLike() string
	SetTitleLike(titleLike string) MediaQueryInterface

	HasType() bool
	Type() string
	SetType(mediaType string) MediaQueryInterface
	// contains filtered or unexported methods
}

func NewMediaQuery

func NewMediaQuery() MediaQueryInterface

type NewStoreOptions

type NewStoreOptions struct {
	CategoryTableName      string
	DiscountTableName      string
	MediaTableName         string
	OrderTableName         string
	OrderLineItemTableName string
	ProductTableName       string
	DB                     *sql.DB
	DbDriverName           string
	AutomigrateEnabled     bool
	DebugEnabled           bool
}

NewStoreOptions define the options for creating a new block store

type Order

type Order struct {
	dataobject.DataObject
}

Order represents a customer order in the shop store. Orders track customer purchases with status workflow, pricing, quantity management, soft deletion, and metadata storage. Supports various order states from pending to completed.

func (*Order) GetCreatedAt added in v1.9.0

func (order *Order) GetCreatedAt() string

GetCreatedAt returns the creation timestamp as a string.

func (*Order) GetCreatedAtCarbon added in v1.9.0

func (order *Order) GetCreatedAtCarbon() *carbon.Carbon

GetCreatedAtCarbon returns the creation timestamp as a Carbon instance.

func (*Order) GetCustomerID added in v1.9.0

func (order *Order) GetCustomerID() string

GetCustomerID returns the customer ID.

func (*Order) GetID added in v1.9.0

func (order *Order) GetID() string

GetID returns the unique identifier.

func (*Order) GetMemo added in v1.9.0

func (order *Order) GetMemo() string

GetMemo returns the internal memo.

func (*Order) GetMeta added in v1.9.0

func (order *Order) GetMeta(name string) string

GetMeta returns a specific metadata value by name. Returns empty string if not found.

func (*Order) GetMetas added in v1.9.0

func (order *Order) GetMetas() (map[string]string, error)

GetMetas returns all metadata as a map. Returns empty map if no metas stored.

func (*Order) GetPrice added in v1.9.0

func (order *Order) GetPrice() string

GetPrice returns the price as a string.

func (*Order) GetPriceFloat added in v1.9.0

func (order *Order) GetPriceFloat() float64

GetPriceFloat returns the price as a float64.

func (*Order) GetQuantity added in v1.9.0

func (order *Order) GetQuantity() string

GetQuantity returns the quantity as a string.

func (*Order) GetQuantityInt added in v1.9.0

func (order *Order) GetQuantityInt() int64

GetQuantityInt returns the quantity as an int64.

func (*Order) GetSoftDeletedAt added in v1.9.0

func (order *Order) GetSoftDeletedAt() string

GetSoftDeletedAt returns the soft deletion timestamp.

func (*Order) GetSoftDeletedAtCarbon added in v1.9.0

func (order *Order) GetSoftDeletedAtCarbon() *carbon.Carbon

GetSoftDeletedAtCarbon returns the soft deletion timestamp as a Carbon instance.

func (*Order) GetStatus added in v1.9.0

func (order *Order) GetStatus() string

GetStatus returns the current status.

func (*Order) GetUpdatedAt added in v1.9.0

func (order *Order) GetUpdatedAt() string

GetUpdatedAt returns the last update timestamp.

func (*Order) GetUpdatedAtCarbon added in v1.9.0

func (order *Order) GetUpdatedAtCarbon() *carbon.Carbon

GetUpdatedAtCarbon returns the last update timestamp as a Carbon instance.

func (*Order) IsAwaitingFulfillment

func (order *Order) IsAwaitingFulfillment() bool

IsAwaitingFulfillment returns true if order status is awaiting fulfillment.

func (*Order) IsAwaitingPayment

func (order *Order) IsAwaitingPayment() bool

IsAwaitingPayment returns true if order status is awaiting payment.

func (*Order) IsAwaitingPickup

func (order *Order) IsAwaitingPickup() bool

IsAwaitingPickup returns true if order status is awaiting pickup.

func (*Order) IsAwaitingShipment

func (order *Order) IsAwaitingShipment() bool

IsAwaitingShipment returns true if order status is awaiting shipment.

func (*Order) IsCancelled

func (order *Order) IsCancelled() bool

IsCancelled returns true if order status is cancelled.

func (*Order) IsCompleted

func (order *Order) IsCompleted() bool

IsCompleted returns true if order status is completed.

func (*Order) IsDeclined

func (order *Order) IsDeclined() bool

IsDeclined returns true if order status is declined.

func (*Order) IsDisputed

func (order *Order) IsDisputed() bool

IsDisputed returns true if order status is disputed.

func (*Order) IsManualVerificationRequired

func (order *Order) IsManualVerificationRequired() bool

IsManualVerificationRequired returns true if order requires manual verification.

func (*Order) IsPending

func (order *Order) IsPending() bool

IsPending returns true if order status is pending.

func (*Order) IsRefunded

func (order *Order) IsRefunded() bool

IsRefunded returns true if order status is refunded.

func (*Order) IsShipped

func (order *Order) IsShipped() bool

IsShipped returns true if order status is shipped.

func (*Order) MetaRemove added in v1.9.0

func (order *Order) MetaRemove(name string) error

MetaRemove removes a single metadata entry.

func (*Order) MetasRemove added in v1.9.0

func (order *Order) MetasRemove(names []string) error

MetasRemove removes multiple metadata entries.

func (*Order) MetasUpsert added in v1.9.0

func (order *Order) MetasUpsert(metas map[string]string) error

MetasUpsert merges the provided metadata with existing values.

func (*Order) SetCreatedAt

func (order *Order) SetCreatedAt(createdAt string) OrderInterface

SetCreatedAt sets the creation timestamp.

func (*Order) SetCustomerID

func (order *Order) SetCustomerID(id string) OrderInterface

SetCustomerID sets the customer ID.

func (*Order) SetID

func (order *Order) SetID(id string) OrderInterface

SetID sets the unique identifier.

func (*Order) SetMemo

func (order *Order) SetMemo(memo string) OrderInterface

SetMemo sets the internal memo.

func (*Order) SetMeta

func (order *Order) SetMeta(name string, value string) error

SetMeta sets a single metadata value.

func (*Order) SetMetas

func (order *Order) SetMetas(metas map[string]string) error

SetMetas replaces all metadata with the provided map. Warning: this overwrites any existing metadata.

func (*Order) SetPrice

func (order *Order) SetPrice(price string) OrderInterface

SetPrice sets the price from a string.

func (*Order) SetPriceFloat

func (order *Order) SetPriceFloat(price float64) OrderInterface

SetPriceFloat sets the price from a float64.

func (*Order) SetQuantity

func (order *Order) SetQuantity(quantity string) OrderInterface

SetQuantity sets the quantity from a string.

func (*Order) SetQuantityInt

func (order *Order) SetQuantityInt(quantity int64) OrderInterface

SetQuantityInt sets the quantity from an int64.

func (*Order) SetSoftDeletedAt

func (order *Order) SetSoftDeletedAt(deletedAt string) OrderInterface

SetSoftDeletedAt sets the soft deletion timestamp.

func (*Order) SetStatus

func (order *Order) SetStatus(status string) OrderInterface

SetStatus sets the current status.

func (*Order) SetUpdatedAt

func (order *Order) SetUpdatedAt(updatedAt string) OrderInterface

SetUpdatedAt sets the last update timestamp.

type OrderInterface

type OrderInterface interface {

	// Data returns a map of all field values for serialization.
	Data() map[string]string
	// DataChanged returns a map of only the fields that have been modified since load.
	DataChanged() map[string]string
	// MarkAsNotDirty resets the dirty state, clearing all change tracking.
	MarkAsNotDirty()

	// IsAwaitingFulfillment returns true if order is awaiting fulfillment.
	IsAwaitingFulfillment() bool
	// IsAwaitingPayment returns true if order is awaiting payment.
	IsAwaitingPayment() bool
	// IsAwaitingPickup returns true if order is awaiting pickup.
	IsAwaitingPickup() bool
	// IsAwaitingShipment returns true if order is awaiting shipment.
	IsAwaitingShipment() bool
	// IsCancelled returns true if order is cancelled.
	IsCancelled() bool
	// IsCompleted returns true if order is completed.
	IsCompleted() bool
	// IsDeclined returns true if order is declined.
	IsDeclined() bool
	// IsDisputed returns true if order is disputed.
	IsDisputed() bool
	// IsManualVerificationRequired returns true if order requires manual verification.
	IsManualVerificationRequired() bool
	// IsPending returns true if order is pending.
	IsPending() bool
	// IsRefunded returns true if order is refunded.
	IsRefunded() bool
	// IsShipped returns true if order is shipped.
	IsShipped() bool

	// GetCreatedAt returns the creation timestamp as a string.
	GetCreatedAt() string
	// GetCreatedAtCarbon returns the creation timestamp as a Carbon instance.
	GetCreatedAtCarbon() *carbon.Carbon
	// SetCreatedAt sets the creation timestamp.
	SetCreatedAt(createdAt string) OrderInterface

	// GetCustomerID returns the customer ID.
	GetCustomerID() string
	// SetCustomerID sets the customer ID.
	SetCustomerID(customerID string) OrderInterface

	// GetID returns the unique identifier.
	GetID() string
	// SetID sets the unique identifier.
	SetID(id string) OrderInterface

	// GetMemo returns the internal memo.
	GetMemo() string
	// SetMemo sets the internal memo.
	SetMemo(memo string) OrderInterface

	// GetMeta returns a specific metadata value by name.
	GetMeta(name string) string
	// SetMeta sets a single metadata value.
	SetMeta(name string, value string) error
	// GetMetas returns all metadata as a map.
	GetMetas() (map[string]string, error)
	// SetMetas replaces all metadata with the provided map.
	SetMetas(metas map[string]string) error
	// MetasUpsert merges the provided metadata with existing values.
	MetasUpsert(metas map[string]string) error
	// MetaRemove removes a single metadata entry.
	MetaRemove(name string) error
	// MetasRemove removes multiple metadata entries.
	MetasRemove(names []string) error

	// GetPrice returns the price as a string.
	GetPrice() string
	// SetPrice sets the price from a string.
	SetPrice(price string) OrderInterface
	// GetPriceFloat returns the price as a float64.
	GetPriceFloat() float64
	// SetPriceFloat sets the price from a float64.
	SetPriceFloat(price float64) OrderInterface

	// GetQuantity returns the quantity as a string.
	GetQuantity() string
	// SetQuantity sets the quantity from a string.
	SetQuantity(quantity string) OrderInterface
	// GetQuantityInt returns the quantity as an int64.
	GetQuantityInt() int64
	// SetQuantityInt sets the quantity from an int64.
	SetQuantityInt(quantity int64) OrderInterface

	// GetSoftDeletedAt returns the soft deletion timestamp.
	GetSoftDeletedAt() string
	// GetSoftDeletedAtCarbon returns the soft deletion timestamp as a Carbon instance.
	GetSoftDeletedAtCarbon() *carbon.Carbon
	// SetSoftDeletedAt sets the soft deletion timestamp.
	SetSoftDeletedAt(deletedAt string) OrderInterface

	// GetStatus returns the current status.
	GetStatus() string
	// SetStatus sets the current status.
	SetStatus(status string) OrderInterface

	// GetUpdatedAt returns the last update timestamp.
	GetUpdatedAt() string
	// GetUpdatedAtCarbon returns the last update timestamp as a Carbon instance.
	GetUpdatedAtCarbon() *carbon.Carbon
	// SetUpdatedAt sets the last update timestamp.
	SetUpdatedAt(updatedAt string) OrderInterface
}

OrderInterface defines the contract for order entities. Orders track customer purchases with status workflow, pricing, quantity management, soft deletion, and metadata storage. Supports various order states from pending to completed.

func NewOrder

func NewOrder() OrderInterface

NewOrder creates a new order with default values: - Status: pending - Quantity: 1 - Price: 0.00 (free) - Memo: empty - CreatedAt: current UTC time - UpdatedAt: current UTC time - SoftDeletedAt: max datetime (not deleted) - Metas: empty map

func NewOrderFromExistingData

func NewOrderFromExistingData(data map[string]string) OrderInterface

NewOrderFromExistingData creates an order from existing data map. Used when hydrating from database or external sources.

type OrderLineItem

type OrderLineItem struct {
	dataobject.DataObject
}

OrderLineItem represents an individual product within an order. Line items track their own pricing, quantity, product association, and status. Supports soft deletion and metadata storage.

func (*OrderLineItem) GetCreatedAt added in v1.9.0

func (o *OrderLineItem) GetCreatedAt() string

GetCreatedAt returns the creation timestamp as a string.

func (*OrderLineItem) GetCreatedAtCarbon added in v1.9.0

func (o *OrderLineItem) GetCreatedAtCarbon() *carbon.Carbon

GetCreatedAtCarbon returns the creation timestamp as a Carbon instance.

func (*OrderLineItem) GetID added in v1.9.0

func (o *OrderLineItem) GetID() string

GetID returns the unique identifier.

func (*OrderLineItem) GetMemo added in v1.9.0

func (o *OrderLineItem) GetMemo() string

GetMemo returns the internal memo.

func (*OrderLineItem) GetMeta added in v1.9.0

func (o *OrderLineItem) GetMeta(name string) string

GetMeta returns a specific metadata value by name. Returns empty string if not found.

func (*OrderLineItem) GetMetas added in v1.9.0

func (o *OrderLineItem) GetMetas() (map[string]string, error)

GetMetas returns all metadata as a map. Returns empty map if no metas stored.

func (*OrderLineItem) GetOrderID added in v1.9.0

func (o *OrderLineItem) GetOrderID() string

GetOrderID returns the associated order ID.

func (*OrderLineItem) GetPrice added in v1.9.0

func (o *OrderLineItem) GetPrice() string

GetPrice returns the price as a string.

func (*OrderLineItem) GetPriceFloat added in v1.9.0

func (o *OrderLineItem) GetPriceFloat() float64

GetPriceFloat returns the price as a float64.

func (*OrderLineItem) GetProductID added in v1.9.0

func (o *OrderLineItem) GetProductID() string

GetProductID returns the associated product ID.

func (*OrderLineItem) GetQuantity added in v1.9.0

func (o *OrderLineItem) GetQuantity() string

GetQuantity returns the quantity as a string.

func (*OrderLineItem) GetQuantityInt added in v1.9.0

func (o *OrderLineItem) GetQuantityInt() int64

GetQuantityInt returns the quantity as an int64.

func (*OrderLineItem) GetSoftDeletedAt added in v1.9.0

func (o *OrderLineItem) GetSoftDeletedAt() string

GetSoftDeletedAt returns the soft deletion timestamp.

func (*OrderLineItem) GetSoftDeletedAtCarbon added in v1.9.0

func (o *OrderLineItem) GetSoftDeletedAtCarbon() *carbon.Carbon

GetSoftDeletedAtCarbon returns the soft deletion timestamp as a Carbon instance.

func (*OrderLineItem) GetStatus added in v1.9.0

func (o *OrderLineItem) GetStatus() string

GetStatus returns the current status.

func (*OrderLineItem) GetTitle added in v1.9.0

func (o *OrderLineItem) GetTitle() string

GetTitle returns the line item title.

func (*OrderLineItem) GetUpdatedAt added in v1.9.0

func (o *OrderLineItem) GetUpdatedAt() string

GetUpdatedAt returns the last update timestamp.

func (*OrderLineItem) GetUpdatedAtCarbon added in v1.9.0

func (o *OrderLineItem) GetUpdatedAtCarbon() *carbon.Carbon

GetUpdatedAtCarbon returns the last update timestamp as a Carbon instance.

func (*OrderLineItem) HasQuantity added in v1.9.0

func (o *OrderLineItem) HasQuantity() bool

HasQuantity returns true if the quantity is greater than 0.

func (*OrderLineItem) IsActive added in v1.9.0

func (o *OrderLineItem) IsActive() bool

IsActive returns true if the order line item is in an active state.

func (*OrderLineItem) IsCancelled added in v1.9.0

func (o *OrderLineItem) IsCancelled() bool

IsCancelled returns true if the order line item is cancelled.

func (*OrderLineItem) IsCompleted added in v1.9.0

func (o *OrderLineItem) IsCompleted() bool

IsCompleted returns true if the order line item is completed.

func (*OrderLineItem) IsDraft added in v1.9.0

func (o *OrderLineItem) IsDraft() bool

IsDraft returns true if the order line item is in draft/pending state.

func (*OrderLineItem) IsFree added in v1.9.0

func (o *OrderLineItem) IsFree() bool

IsFree returns true if the price is less than or equal to 0.

func (*OrderLineItem) MetaRemove added in v1.9.0

func (o *OrderLineItem) MetaRemove(name string) error

MetaRemove removes a single metadata entry.

func (*OrderLineItem) MetasRemove added in v1.9.0

func (o *OrderLineItem) MetasRemove(names []string) error

MetasRemove removes multiple metadata entries.

func (*OrderLineItem) MetasUpsert added in v1.9.0

func (o *OrderLineItem) MetasUpsert(metas map[string]string) error

MetasUpsert merges the provided metadata with existing values.

func (*OrderLineItem) SetCreatedAt

func (o *OrderLineItem) SetCreatedAt(createdAt string) OrderLineItemInterface

SetCreatedAt sets the creation timestamp.

func (*OrderLineItem) SetID

SetID sets the unique identifier.

func (*OrderLineItem) SetMemo

func (o *OrderLineItem) SetMemo(memo string) OrderLineItemInterface

SetMemo sets the internal memo.

func (*OrderLineItem) SetMeta

func (o *OrderLineItem) SetMeta(name string, value string) error

SetMeta sets a single metadata value.

func (*OrderLineItem) SetMetas

func (o *OrderLineItem) SetMetas(metas map[string]string) error

SetMetas replaces all metadata with the provided map. Warning: this overwrites any existing metadata.

func (*OrderLineItem) SetOrderID

func (o *OrderLineItem) SetOrderID(orderID string) OrderLineItemInterface

SetOrderID sets the associated order ID.

func (*OrderLineItem) SetPrice

func (o *OrderLineItem) SetPrice(price string) OrderLineItemInterface

SetPrice sets the price from a string.

func (*OrderLineItem) SetPriceFloat

func (o *OrderLineItem) SetPriceFloat(price float64) OrderLineItemInterface

SetPriceFloat sets the price from a float64.

func (*OrderLineItem) SetProductID

func (o *OrderLineItem) SetProductID(productID string) OrderLineItemInterface

SetProductID sets the associated product ID.

func (*OrderLineItem) SetQuantity

func (o *OrderLineItem) SetQuantity(quantity string) OrderLineItemInterface

SetQuantity sets the quantity from a string.

func (*OrderLineItem) SetQuantityInt

func (o *OrderLineItem) SetQuantityInt(quantity int64) OrderLineItemInterface

SetQuantityInt sets the quantity from an int64.

func (*OrderLineItem) SetSoftDeletedAt

func (o *OrderLineItem) SetSoftDeletedAt(deletedAt string) OrderLineItemInterface

SetSoftDeletedAt sets the soft deletion timestamp.

func (*OrderLineItem) SetStatus

func (o *OrderLineItem) SetStatus(status string) OrderLineItemInterface

SetStatus sets the current status.

func (*OrderLineItem) SetTitle

func (o *OrderLineItem) SetTitle(title string) OrderLineItemInterface

SetTitle sets the line item title.

func (*OrderLineItem) SetUpdatedAt

func (o *OrderLineItem) SetUpdatedAt(updatedAt string) OrderLineItemInterface

SetUpdatedAt sets the last update timestamp.

type OrderLineItemInterface

type OrderLineItemInterface interface {

	// Data returns a map of all field values for serialization.
	Data() map[string]string
	// DataChanged returns a map of only the fields that have been modified since load.
	DataChanged() map[string]string
	// MarkAsNotDirty resets the dirty state, clearing all change tracking.
	MarkAsNotDirty()

	// GetCreatedAt returns the creation timestamp as a string.
	GetCreatedAt() string
	// GetCreatedAtCarbon returns the creation timestamp as a Carbon instance.
	GetCreatedAtCarbon() *carbon.Carbon
	// SetCreatedAt sets the creation timestamp.
	SetCreatedAt(createdAt string) OrderLineItemInterface

	// GetID returns the unique identifier.
	GetID() string
	// SetID sets the unique identifier.
	SetID(id string) OrderLineItemInterface

	// GetMemo returns the internal memo.
	GetMemo() string
	// SetMemo sets the internal memo.
	SetMemo(memo string) OrderLineItemInterface

	// GetMetas returns all metadata as a map.
	GetMetas() (map[string]string, error)
	// SetMetas replaces all metadata with the provided map.
	SetMetas(metas map[string]string) error
	// GetMeta returns a specific metadata value by name.
	GetMeta(name string) string
	// SetMeta sets a single metadata value.
	SetMeta(name string, value string) error
	// MetasUpsert merges the provided metadata with existing values.
	MetasUpsert(metas map[string]string) error
	// MetaRemove removes a single metadata entry.
	MetaRemove(name string) error
	// MetasRemove removes multiple metadata entries.
	MetasRemove(names []string) error

	// GetOrderID returns the associated order ID.
	GetOrderID() string
	// SetOrderID sets the associated order ID.
	SetOrderID(orderID string) OrderLineItemInterface

	// GetPrice returns the price as a string.
	GetPrice() string
	// SetPrice sets the price from a string.
	SetPrice(price string) OrderLineItemInterface
	// GetPriceFloat returns the price as a float64.
	GetPriceFloat() float64
	// SetPriceFloat sets the price from a float64.
	SetPriceFloat(price float64) OrderLineItemInterface

	// GetProductID returns the associated product ID.
	GetProductID() string
	// SetProductID sets the associated product ID.
	SetProductID(productID string) OrderLineItemInterface

	// GetQuantity returns the quantity as a string.
	GetQuantity() string
	// SetQuantity sets the quantity from a string.
	SetQuantity(quantity string) OrderLineItemInterface
	// GetQuantityInt returns the quantity as an int64.
	GetQuantityInt() int64
	// SetQuantityInt sets the quantity from an int64.
	SetQuantityInt(quantity int64) OrderLineItemInterface

	// GetSoftDeletedAt returns the soft deletion timestamp.
	GetSoftDeletedAt() string
	// GetSoftDeletedAtCarbon returns the soft deletion timestamp as a Carbon instance.
	GetSoftDeletedAtCarbon() *carbon.Carbon
	// SetSoftDeletedAt sets the soft deletion timestamp.
	SetSoftDeletedAt(deletedAt string) OrderLineItemInterface

	// GetStatus returns the current status.
	GetStatus() string
	// SetStatus sets the current status.
	SetStatus(status string) OrderLineItemInterface

	// GetTitle returns the line item title.
	GetTitle() string
	// SetTitle sets the line item title.
	SetTitle(title string) OrderLineItemInterface

	// GetUpdatedAt returns the last update timestamp.
	GetUpdatedAt() string
	// GetUpdatedAtCarbon returns the last update timestamp as a Carbon instance.
	GetUpdatedAtCarbon() *carbon.Carbon
	// SetUpdatedAt sets the last update timestamp.
	SetUpdatedAt(updatedAt string) OrderLineItemInterface

	// IsActive returns true if status is active.
	IsActive() bool
	// IsCancelled returns true if status is cancelled.
	IsCancelled() bool
	// IsCompleted returns true if status is completed.
	IsCompleted() bool
	// IsDraft returns true if status is draft.
	IsDraft() bool

	// HasQuantity returns true if quantity is greater than zero.
	HasQuantity() bool
	// IsFree returns true if price is zero.
	IsFree() bool
}

OrderLineItemInterface defines the contract for order line item entities. Line items represent individual products within an order with their own pricing, quantity, and status tracking. Supports soft deletion and metadata storage.

func NewOrderLineItem

func NewOrderLineItem() OrderLineItemInterface

NewOrderLineItem creates a new order line item with default values: - Status: pending - Title: empty - Quantity: 1 - Price: 0.00 (free) - Memo: empty - CreatedAt: current UTC time - UpdatedAt: current UTC time - SoftDeletedAt: max datetime (not deleted) - Metas: empty map

func NewOrderLineItemFromExistingData

func NewOrderLineItemFromExistingData(data map[string]string) OrderLineItemInterface

NewOrderLineItemFromExistingData creates an order line item from existing data map. Used when hydrating from database or external sources.

type OrderLineItemQueryInterface

type OrderLineItemQueryInterface interface {
	Validate() error

	Columns() []string
	SetColumns(columns []string) OrderLineItemQueryInterface

	HasCountOnly() bool
	IsCountOnly() bool
	SetCountOnly(countOnly bool) OrderLineItemQueryInterface

	HasCreatedAtGte() bool
	CreatedAtGte() string
	SetCreatedAtGte(createdAtGte string) OrderLineItemQueryInterface

	HasCreatedAtLte() bool
	CreatedAtLte() string
	SetCreatedAtLte(createdAtLte string) OrderLineItemQueryInterface

	HasID() bool
	ID() string
	SetID(id string) OrderLineItemQueryInterface

	HasIDIn() bool
	IDIn() []string
	SetIDIn(idIn []string) OrderLineItemQueryInterface

	HasLimit() bool
	Limit() int
	SetLimit(limit int) OrderLineItemQueryInterface

	HasOffset() bool
	Offset() int
	SetOffset(offset int) OrderLineItemQueryInterface

	HasOrderBy() bool
	OrderBy() string
	SetOrderBy(orderBy string) OrderLineItemQueryInterface

	HasOrderID() bool
	OrderID() string
	SetOrderID(orderID string) OrderLineItemQueryInterface

	HasOrderIDIn() bool
	OrderIDIn() []string
	SetOrderIDIn(orderIDIn []string) OrderLineItemQueryInterface

	HasProductID() bool
	ProductID() string
	SetProductID(productID string) OrderLineItemQueryInterface

	HasSortDirection() bool
	SortDirection() string
	SetSortDirection(sortDirection string) OrderLineItemQueryInterface

	HasSoftDeletedIncluded() bool
	SoftDeletedIncluded() bool
	SetSoftDeletedIncluded(softDeletedIncluded bool) OrderLineItemQueryInterface

	HasStatus() bool
	Status() string
	SetStatus(status string) OrderLineItemQueryInterface

	HasStatusIn() bool
	StatusIn() []string
	SetStatusIn(statusIn []string) OrderLineItemQueryInterface
	// contains filtered or unexported methods
}

func NewOrderLineItemQuery

func NewOrderLineItemQuery() OrderLineItemQueryInterface

type OrderQueryInterface

type OrderQueryInterface interface {
	Validate() error

	Columns() []string
	SetColumns(columns []string) OrderQueryInterface

	HasCountOnly() bool
	IsCountOnly() bool
	SetCountOnly(countOnly bool) OrderQueryInterface

	HasCreatedAtGte() bool
	CreatedAtGte() string
	SetCreatedAtGte(createdAtGte string) OrderQueryInterface

	HasCreatedAtLte() bool
	CreatedAtLte() string
	SetCreatedAtLte(createdAtLte string) OrderQueryInterface

	HasCustomerID() bool
	CustomerID() string
	SetCustomerID(customerID string) OrderQueryInterface

	HasID() bool
	ID() string
	SetID(id string) OrderQueryInterface

	HasIDIn() bool
	IDIn() []string
	SetIDIn(idIn []string) OrderQueryInterface

	HasLimit() bool
	Limit() int
	SetLimit(limit int) OrderQueryInterface

	HasOffset() bool
	Offset() int
	SetOffset(offset int) OrderQueryInterface

	HasOrderBy() bool
	OrderBy() string
	SetOrderBy(orderBy string) OrderQueryInterface

	HasSortDirection() bool
	SortDirection() string
	SetSortDirection(sortDirection string) OrderQueryInterface

	HasSoftDeletedIncluded() bool
	SoftDeletedIncluded() bool
	SetSoftDeletedIncluded(softDeletedIncluded bool) OrderQueryInterface

	HasStatus() bool
	Status() string
	SetStatus(status string) OrderQueryInterface

	HasStatusIn() bool
	StatusIn() []string
	SetStatusIn(statusIn []string) OrderQueryInterface
	// contains filtered or unexported methods
}

func NewOrderQuery

func NewOrderQuery() OrderQueryInterface

type Product

type Product struct {
	dataobject.DataObject
}

Product represents a product in the shop store. Products support parent-child relationships (variants), pricing, stock management, variant matrix configuration, soft deletion, metadata storage, and status management.

func (*Product) GetCreatedAt added in v1.9.0

func (product *Product) GetCreatedAt() string

GetCreatedAt returns the creation timestamp as a string.

func (*Product) GetCreatedAtCarbon added in v1.9.0

func (product *Product) GetCreatedAtCarbon() *carbon.Carbon

GetCreatedAtCarbon returns the creation timestamp as a Carbon instance.

func (*Product) GetDescription added in v1.9.0

func (product *Product) GetDescription() string

GetDescription returns the full product description.

func (*Product) GetID added in v1.9.0

func (product *Product) GetID() string

GetID returns the unique identifier.

func (*Product) GetMemo added in v1.9.0

func (product *Product) GetMemo() string

GetMemo returns the internal memo.

func (*Product) GetMeta added in v1.9.0

func (product *Product) GetMeta(name string) string

GetMeta returns a specific metadata value by name. Returns empty string if not found.

func (*Product) GetMetas added in v1.9.0

func (product *Product) GetMetas() (map[string]string, error)

GetMetas returns all metadata as a map. Returns empty map if no metas stored.

func (*Product) GetParentID added in v1.10.0

func (product *Product) GetParentID() string

GetParentID returns the parent product ID (empty if not a variant).

func (*Product) GetPrice added in v1.9.0

func (product *Product) GetPrice() string

GetPrice returns the price as a string.

func (*Product) GetPriceFloat added in v1.9.0

func (product *Product) GetPriceFloat() float64

GetPriceFloat returns the price as a float64.

func (*Product) GetQuantity added in v1.9.0

func (product *Product) GetQuantity() string

GetQuantity returns the stock quantity as a string.

func (*Product) GetQuantityInt added in v1.9.0

func (product *Product) GetQuantityInt() int64

GetQuantityInt returns the stock quantity as an int64.

func (*Product) GetShortDescription added in v1.9.0

func (product *Product) GetShortDescription() string

GetShortDescription returns the short/abbreviated description.

func (*Product) GetSoftDeletedAt added in v1.9.0

func (product *Product) GetSoftDeletedAt() string

GetSoftDeletedAt returns the soft deletion timestamp.

func (*Product) GetSoftDeletedAtCarbon added in v1.9.0

func (product *Product) GetSoftDeletedAtCarbon() *carbon.Carbon

GetSoftDeletedAtCarbon returns the soft deletion timestamp as a Carbon instance.

func (*Product) GetStatus added in v1.9.0

func (product *Product) GetStatus() string

GetStatus returns the current status.

func (*Product) GetTitle added in v1.9.0

func (product *Product) GetTitle() string

GetTitle returns the product title.

func (*Product) GetUpdatedAt added in v1.9.0

func (product *Product) GetUpdatedAt() string

GetUpdatedAt returns the last update timestamp.

func (*Product) GetUpdatedAtCarbon added in v1.9.0

func (product *Product) GetUpdatedAtCarbon() *carbon.Carbon

GetUpdatedAtCarbon returns the last update timestamp as a Carbon instance.

func (*Product) GetVariantMatrixSchema added in v1.10.0

func (product *Product) GetVariantMatrixSchema() (VariantMatrixSchema, error)

GetVariantMatrixSchema returns the variant matrix schema configuration.

func (*Product) GetVariantMatrixValues added in v1.10.0

func (product *Product) GetVariantMatrixValues() (map[string]string, error)

GetVariantMatrixValues returns the variant attribute values for this product.

func (*Product) HasStock added in v1.9.0

func (product *Product) HasStock() bool

HasStock returns true if the product quantity is greater than 0.

func (*Product) HasVariantMatrixSchema added in v1.10.0

func (product *Product) HasVariantMatrixSchema() bool

HasVariantMatrixSchema returns true if a variant matrix schema is defined.

func (*Product) IsActive

func (product *Product) IsActive() bool

IsActive returns true if the product status is active.

func (*Product) IsDisabled

func (product *Product) IsDisabled() bool

IsDisabled returns true if the product status is disabled.

func (*Product) IsDraft

func (product *Product) IsDraft() bool

IsDraft returns true if the product status is draft.

func (*Product) IsFree

func (product *Product) IsFree() bool

IsFree returns true if the product price is less than or equal to 0.

func (*Product) IsOutOfStock added in v1.9.0

func (product *Product) IsOutOfStock() bool

IsOutOfStock returns true if the product quantity is less than or equal to 0.

func (*Product) IsPaid added in v1.9.0

func (product *Product) IsPaid() bool

IsPaid returns true if the product price is greater than 0.

func (*Product) IsParent added in v1.10.0

func (product *Product) IsParent() bool

IsParent returns true if this product has variants (has variant matrix schema).

func (*Product) IsSoftDeleted

func (product *Product) IsSoftDeleted() bool

IsSoftDeleted returns true if the product is soft deleted.

func (*Product) IsVariant added in v1.10.0

func (product *Product) IsVariant() bool

IsVariant returns true if this product is a variant of another product.

func (*Product) MetaRemove added in v1.9.0

func (product *Product) MetaRemove(name string) error

MetaRemove removes a single metadata entry.

func (*Product) MetasRemove added in v1.9.0

func (product *Product) MetasRemove(names []string) error

MetasRemove removes multiple metadata entries.

func (*Product) MetasUpsert added in v1.9.0

func (product *Product) MetasUpsert(metas map[string]string) error

MetasUpsert merges the provided metadata with existing values.

func (*Product) SetCreatedAt

func (product *Product) SetCreatedAt(createdAt string) ProductInterface

SetCreatedAt sets the creation timestamp.

func (*Product) SetDescription

func (product *Product) SetDescription(description string) ProductInterface

SetDescription sets the full product description.

func (*Product) SetID

func (product *Product) SetID(id string) ProductInterface

SetID sets the unique identifier.

func (*Product) SetMemo

func (product *Product) SetMemo(memo string) ProductInterface

SetMemo sets the internal memo.

func (*Product) SetMeta

func (product *Product) SetMeta(name string, value string) error

SetMeta sets a single metadata value.

func (*Product) SetMetas

func (product *Product) SetMetas(metas map[string]string) error

SetMetas replaces all metadata with the provided map. Warning: this overwrites any existing metadata.

func (*Product) SetParentID added in v1.10.0

func (product *Product) SetParentID(parentID string) ProductInterface

SetParentID sets the parent product ID.

func (*Product) SetPrice

func (product *Product) SetPrice(price string) ProductInterface

SetPrice sets the price from a string.

func (*Product) SetPriceFloat

func (product *Product) SetPriceFloat(price float64) ProductInterface

SetPriceFloat sets the price from a float64.

func (*Product) SetQuantity

func (product *Product) SetQuantity(quantity string) ProductInterface

SetQuantity sets the stock quantity from a string.

func (*Product) SetQuantityInt

func (product *Product) SetQuantityInt(quantity int64) ProductInterface

SetQuantityInt sets the stock quantity from an int64.

func (*Product) SetShortDescription

func (product *Product) SetShortDescription(shortDescription string) ProductInterface

SetShortDescription sets the short/abbreviated description.

func (*Product) SetSoftDeletedAt

func (product *Product) SetSoftDeletedAt(deletedAt string) ProductInterface

SetSoftDeletedAt sets the soft deletion timestamp.

func (*Product) SetStatus

func (product *Product) SetStatus(status string) ProductInterface

SetStatus sets the current status.

func (*Product) SetTitle

func (product *Product) SetTitle(title string) ProductInterface

SetTitle sets the product title.

func (*Product) SetUpdatedAt

func (product *Product) SetUpdatedAt(updatedAt string) ProductInterface

SetUpdatedAt sets the last update timestamp.

func (*Product) SetVariantMatrixSchema added in v1.10.0

func (product *Product) SetVariantMatrixSchema(schema VariantMatrixSchema) error

SetVariantMatrixSchema sets the variant matrix schema configuration.

func (*Product) SetVariantMatrixValues added in v1.10.0

func (product *Product) SetVariantMatrixValues(values map[string]string) error

SetVariantMatrixValues sets the variant attribute values for this product.

func (*Product) Slug

func (product *Product) Slug() string

Slug returns the URL-friendly slug generated from the product title.

type ProductInterface

type ProductInterface interface {

	// Data returns a map of all field values for serialization.
	Data() map[string]string
	// DataChanged returns a map of only the fields that have been modified since load.
	DataChanged() map[string]string
	// MarkAsNotDirty resets the dirty state, clearing all change tracking.
	MarkAsNotDirty()

	// IsActive returns true if status is active.
	IsActive() bool
	// IsDisabled returns true if status is disabled.
	IsDisabled() bool
	// IsDraft returns true if status is draft.
	IsDraft() bool
	// IsParent returns true if this product has variants (has variant matrix schema).
	IsParent() bool
	// IsSoftDeleted returns true if the product is soft deleted.
	IsSoftDeleted() bool
	// IsFree returns true if price is zero.
	IsFree() bool
	// IsVariant returns true if this product is a variant of another product.
	IsVariant() bool
	// Slug returns the URL-friendly slug for the product.
	Slug() string

	// HasStock returns true if quantity is greater than zero.
	HasStock() bool
	// IsOutOfStock returns true if quantity is zero.
	IsOutOfStock() bool

	// IsPaid returns true if price is greater than zero.
	IsPaid() bool

	// GetCreatedAt returns the creation timestamp as a string.
	GetCreatedAt() string
	// GetCreatedAtCarbon returns the creation timestamp as a Carbon instance.
	GetCreatedAtCarbon() *carbon.Carbon
	// SetCreatedAt sets the creation timestamp.
	SetCreatedAt(createdAt string) ProductInterface

	// GetDescription returns the full product description.
	GetDescription() string
	// SetDescription sets the full product description.
	SetDescription(description string) ProductInterface

	// GetID returns the unique identifier.
	GetID() string
	// SetID sets the unique identifier.
	SetID(id string) ProductInterface

	// GetMemo returns the internal memo.
	GetMemo() string
	// SetMemo sets the internal memo.
	SetMemo(memo string) ProductInterface

	// GetMeta returns a specific metadata value by name.
	GetMeta(name string) string
	// SetMeta sets a single metadata value.
	SetMeta(name string, value string) error

	// GetMetas returns all metadata as a map.
	GetMetas() (map[string]string, error)
	// SetMetas replaces all metadata with the provided map.
	SetMetas(metas map[string]string) error
	// MetasUpsert merges the provided metadata with existing values.
	MetasUpsert(metas map[string]string) error
	// MetaRemove removes a single metadata entry.
	MetaRemove(name string) error
	// MetasRemove removes multiple metadata entries.
	MetasRemove(names []string) error

	// GetParentID returns the parent product ID (empty if not a variant).
	GetParentID() string
	// SetParentID sets the parent product ID.
	SetParentID(parentID string) ProductInterface

	// GetPrice returns the price as a string.
	GetPrice() string
	// SetPrice sets the price from a string.
	SetPrice(price string) ProductInterface
	// GetPriceFloat returns the price as a float64.
	GetPriceFloat() float64
	// SetPriceFloat sets the price from a float64.
	SetPriceFloat(price float64) ProductInterface

	// GetQuantity returns the stock quantity as a string.
	GetQuantity() string
	// SetQuantity sets the stock quantity from a string.
	SetQuantity(quantity string) ProductInterface
	// GetQuantityInt returns the stock quantity as an int64.
	GetQuantityInt() int64
	// SetQuantityInt sets the stock quantity from an int64.
	SetQuantityInt(quantity int64) ProductInterface

	// GetSoftDeletedAt returns the soft deletion timestamp.
	GetSoftDeletedAt() string
	// GetSoftDeletedAtCarbon returns the soft deletion timestamp as a Carbon instance.
	GetSoftDeletedAtCarbon() *carbon.Carbon
	// SetSoftDeletedAt sets the soft deletion timestamp.
	SetSoftDeletedAt(deletedAt string) ProductInterface

	// GetShortDescription returns the short/abbreviated description.
	GetShortDescription() string
	// SetShortDescription sets the short/abbreviated description.
	SetShortDescription(shortDescription string) ProductInterface

	// GetStatus returns the current status.
	GetStatus() string
	// SetStatus sets the current status.
	SetStatus(status string) ProductInterface

	// GetTitle returns the product title.
	GetTitle() string
	// SetTitle sets the product title.
	SetTitle(title string) ProductInterface

	// GetUpdatedAt returns the last update timestamp.
	GetUpdatedAt() string
	// GetUpdatedAtCarbon returns the last update timestamp as a Carbon instance.
	GetUpdatedAtCarbon() *carbon.Carbon
	// SetUpdatedAt sets the last update timestamp.
	SetUpdatedAt(updatedAt string) ProductInterface

	// GetVariantMatrixSchema returns the variant matrix schema configuration.
	GetVariantMatrixSchema() (VariantMatrixSchema, error)
	// SetVariantMatrixSchema sets the variant matrix schema configuration.
	SetVariantMatrixSchema(schema VariantMatrixSchema) error
	// HasVariantMatrixSchema returns true if a variant matrix schema is defined.
	HasVariantMatrixSchema() bool

	// GetVariantMatrixValues returns the variant attribute values for this product.
	GetVariantMatrixValues() (map[string]string, error)
	// SetVariantMatrixValues sets the variant attribute values for this product.
	SetVariantMatrixValues(values map[string]string) error
}

ProductInterface defines the contract for product entities. Products support parent-child relationships (variants), pricing, stock management, variant matrix configuration, soft deletion, metadata storage, and status management.

func NewProduct

func NewProduct() ProductInterface

NewProduct creates a new product with default values: - Status: draft - Title: empty - Description: empty - ShortDescription: empty - Quantity: 0 - Price: 0.00 (free) - ParentID: empty (not a variant) - Memo: empty - CreatedAt: current UTC time - UpdatedAt: current UTC time - SoftDeletedAt: max datetime (not deleted) - Metas: empty map - VariantMatrixSchema: empty - VariantMatrixValues: empty map

func NewProductFromExistingData

func NewProductFromExistingData(data map[string]string) ProductInterface

NewProductFromExistingData creates a product from existing data map. Used when hydrating from database or external sources.

type ProductQueryInterface

type ProductQueryInterface interface {
	Validate() error

	Columns() []string
	SetColumns(columns []string) ProductQueryInterface

	HasCountOnly() bool
	IsCountOnly() bool
	SetCountOnly(countOnly bool) ProductQueryInterface

	HasCreatedAtGte() bool
	CreatedAtGte() string
	SetCreatedAtGte(createdAtGte string) ProductQueryInterface

	HasCreatedAtLte() bool
	CreatedAtLte() string
	SetCreatedAtLte(createdAtLte string) ProductQueryInterface

	HasID() bool
	ID() string
	SetID(id string) ProductQueryInterface

	HasIDIn() bool
	IDIn() []string
	SetIDIn(idIn []string) ProductQueryInterface

	HasLimit() bool
	Limit() int
	SetLimit(limit int) ProductQueryInterface

	HasOffset() bool
	Offset() int
	SetOffset(offset int) ProductQueryInterface

	HasOrderBy() bool
	OrderBy() string
	SetOrderBy(orderBy string) ProductQueryInterface

	HasSortDirection() bool
	SortDirection() string
	SetSortDirection(sortDirection string) ProductQueryInterface

	HasSoftDeletedIncluded() bool
	SoftDeletedIncluded() bool
	SetSoftDeletedIncluded(softDeletedIncluded bool) ProductQueryInterface

	HasStatus() bool
	Status() string
	SetStatus(status string) ProductQueryInterface

	HasStatusIn() bool
	StatusIn() []string
	SetStatusIn(statusIn []string) ProductQueryInterface

	HasTitleLike() bool
	TitleLike() string
	SetTitleLike(titleLike string) ProductQueryInterface

	HasParentID() bool
	ParentID() string
	SetParentID(parentID string) ProductQueryInterface
	// contains filtered or unexported methods
}

func NewProductQuery

func NewProductQuery() ProductQueryInterface

type Store

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

func NewStore

func NewStore(opts NewStoreOptions) (*Store, error)

NewStore creates a new block store

func (*Store) AutoMigrate

func (store *Store) AutoMigrate() error

AutoMigrate auto migrate

func (*Store) CategoryCount

func (store *Store) CategoryCount(ctx context.Context, options CategoryQueryInterface) (int64, error)

func (*Store) CategoryCreate

func (store *Store) CategoryCreate(ctx context.Context, category CategoryInterface) error

func (*Store) CategoryDelete

func (store *Store) CategoryDelete(ctx context.Context, category CategoryInterface) error

func (*Store) CategoryDeleteByID

func (store *Store) CategoryDeleteByID(ctx context.Context, id string) error

func (*Store) CategoryFindByID

func (store *Store) CategoryFindByID(ctx context.Context, id string) (CategoryInterface, error)

func (*Store) CategoryList

func (store *Store) CategoryList(ctx context.Context, options CategoryQueryInterface) ([]CategoryInterface, error)

func (*Store) CategorySoftDelete

func (store *Store) CategorySoftDelete(ctx context.Context, category CategoryInterface) error

func (*Store) CategorySoftDeleteByID

func (store *Store) CategorySoftDeleteByID(ctx context.Context, id string) error

func (*Store) CategoryTableName

func (store *Store) CategoryTableName() string

func (*Store) CategoryUpdate

func (store *Store) CategoryUpdate(ctx context.Context, category CategoryInterface) (err error)

func (*Store) DB

func (store *Store) DB() *sql.DB

func (*Store) DiscountCount

func (store *Store) DiscountCount(ctx context.Context, options DiscountQueryInterface) (int64, error)

func (*Store) DiscountCreate

func (store *Store) DiscountCreate(ctx context.Context, discount DiscountInterface) error

func (*Store) DiscountDelete

func (store *Store) DiscountDelete(ctx context.Context, discount DiscountInterface) error

func (*Store) DiscountDeleteByID

func (store *Store) DiscountDeleteByID(ctx context.Context, id string) error

func (*Store) DiscountFindByCode

func (store *Store) DiscountFindByCode(ctx context.Context, code string) (DiscountInterface, error)

func (*Store) DiscountFindByID

func (store *Store) DiscountFindByID(ctx context.Context, id string) (DiscountInterface, error)

func (*Store) DiscountList

func (store *Store) DiscountList(ctx context.Context, options DiscountQueryInterface) ([]DiscountInterface, error)

func (*Store) DiscountSoftDelete

func (store *Store) DiscountSoftDelete(ctx context.Context, discount DiscountInterface) error

func (*Store) DiscountSoftDeleteByID

func (store *Store) DiscountSoftDeleteByID(ctx context.Context, id string) error

func (*Store) DiscountTableName

func (store *Store) DiscountTableName() string

func (*Store) DiscountUpdate

func (store *Store) DiscountUpdate(ctx context.Context, discount DiscountInterface) error

func (*Store) EnableDebug

func (store *Store) EnableDebug(debug bool, sqlLogger ...*slog.Logger)

EnableDebug - enables the debug option

func (*Store) MediaCount

func (store *Store) MediaCount(ctx context.Context, options MediaQueryInterface) (int64, error)

func (*Store) MediaCreate

func (store *Store) MediaCreate(ctx context.Context, media MediaInterface) error

func (*Store) MediaDelete

func (store *Store) MediaDelete(ctx context.Context, media MediaInterface) error

func (*Store) MediaDeleteByID

func (store *Store) MediaDeleteByID(ctx context.Context, id string) error

func (*Store) MediaFindByID

func (store *Store) MediaFindByID(ctx context.Context, id string) (MediaInterface, error)

func (*Store) MediaList

func (store *Store) MediaList(ctx context.Context, options MediaQueryInterface) ([]MediaInterface, error)

func (*Store) MediaSoftDelete

func (store *Store) MediaSoftDelete(ctx context.Context, media MediaInterface) error

func (*Store) MediaSoftDeleteByID

func (store *Store) MediaSoftDeleteByID(ctx context.Context, id string) error

func (*Store) MediaTableName

func (store *Store) MediaTableName() string

func (*Store) MediaUpdate

func (store *Store) MediaUpdate(ctx context.Context, media MediaInterface) (err error)

func (*Store) OrderCount

func (store *Store) OrderCount(ctx context.Context, options OrderQueryInterface) (int64, error)

func (*Store) OrderCreate

func (store *Store) OrderCreate(ctx context.Context, order OrderInterface) error

func (*Store) OrderDelete

func (store *Store) OrderDelete(ctx context.Context, order OrderInterface) error

func (*Store) OrderDeleteByID

func (store *Store) OrderDeleteByID(ctx context.Context, id string) error

func (*Store) OrderFindByID

func (store *Store) OrderFindByID(ctx context.Context, id string) (OrderInterface, error)

func (*Store) OrderLineItemCount

func (store *Store) OrderLineItemCount(ctx context.Context, options OrderLineItemQueryInterface) (int64, error)

func (*Store) OrderLineItemCreate

func (store *Store) OrderLineItemCreate(ctx context.Context, orderLineItem OrderLineItemInterface) error

func (*Store) OrderLineItemDelete

func (store *Store) OrderLineItemDelete(ctx context.Context, orderLineItem OrderLineItemInterface) error

func (*Store) OrderLineItemDeleteByID

func (store *Store) OrderLineItemDeleteByID(ctx context.Context, id string) error

func (*Store) OrderLineItemFindByID

func (store *Store) OrderLineItemFindByID(ctx context.Context, id string) (OrderLineItemInterface, error)

func (*Store) OrderLineItemList

func (store *Store) OrderLineItemList(ctx context.Context, options OrderLineItemQueryInterface) ([]OrderLineItemInterface, error)

func (*Store) OrderLineItemSoftDelete

func (store *Store) OrderLineItemSoftDelete(ctx context.Context, orderLineItem OrderLineItemInterface) error

func (*Store) OrderLineItemSoftDeleteByID

func (store *Store) OrderLineItemSoftDeleteByID(ctx context.Context, id string) error

func (*Store) OrderLineItemTableName

func (store *Store) OrderLineItemTableName() string

func (*Store) OrderLineItemUpdate

func (store *Store) OrderLineItemUpdate(ctx context.Context, orderLineItem OrderLineItemInterface) error

func (*Store) OrderList

func (store *Store) OrderList(ctx context.Context, options OrderQueryInterface) ([]OrderInterface, error)

func (*Store) OrderSoftDelete

func (store *Store) OrderSoftDelete(ctx context.Context, order OrderInterface) error

func (*Store) OrderSoftDeleteByID

func (store *Store) OrderSoftDeleteByID(ctx context.Context, id string) error

func (*Store) OrderTableName

func (store *Store) OrderTableName() string

func (*Store) OrderUpdate

func (store *Store) OrderUpdate(ctx context.Context, order OrderInterface) error

func (*Store) ProductCount

func (store *Store) ProductCount(ctx context.Context, options ProductQueryInterface) (int64, error)

func (*Store) ProductCreate

func (store *Store) ProductCreate(ctx context.Context, product ProductInterface) error

func (*Store) ProductDelete

func (store *Store) ProductDelete(ctx context.Context, product ProductInterface) error

func (*Store) ProductDeleteByID

func (store *Store) ProductDeleteByID(ctx context.Context, id string) error

func (*Store) ProductFindByID

func (store *Store) ProductFindByID(ctx context.Context, id string) (ProductInterface, error)

func (*Store) ProductGetParent added in v1.10.0

func (store *Store) ProductGetParent(ctx context.Context, productID string) (ProductInterface, error)

ProductGetParent returns the parent product of a variant

func (*Store) ProductIsParent added in v1.10.0

func (store *Store) ProductIsParent(ctx context.Context, productID string) (bool, error)

ProductIsParent returns true if the product has variants (has variant dimensions defined)

func (*Store) ProductList

func (store *Store) ProductList(ctx context.Context, options ProductQueryInterface) ([]ProductInterface, error)

func (*Store) ProductSoftDelete

func (store *Store) ProductSoftDelete(ctx context.Context, product ProductInterface) error

func (*Store) ProductSoftDeleteByID

func (store *Store) ProductSoftDeleteByID(ctx context.Context, id string) error

func (*Store) ProductTableName

func (store *Store) ProductTableName() string

func (*Store) ProductUpdate

func (store *Store) ProductUpdate(ctx context.Context, product ProductInterface) error

func (*Store) ProductVariantList added in v1.10.0

func (store *Store) ProductVariantList(ctx context.Context, parentID string) ([]ProductInterface, error)

ProductVariantList returns all variants for a given parent product ID

type StoreInterface

type StoreInterface interface {
	// AutoMigrate creates or updates database tables to match the current schema.
	AutoMigrate() error
	// DB returns the underlying SQL database connection.
	DB() *sql.DB
	// EnableDebug enables or disables debug logging for SQL queries.
	EnableDebug(debug bool, sqlLogger ...*slog.Logger)

	// CategoryTableName returns the database table name for categories.
	CategoryTableName() string
	// DiscountTableName returns the database table name for discounts.
	DiscountTableName() string
	// MediaTableName returns the database table name for media.
	MediaTableName() string
	// OrderTableName returns the database table name for orders.
	OrderTableName() string
	// OrderLineItemTableName returns the database table name for order line items.
	OrderLineItemTableName() string
	// ProductTableName returns the database table name for products.
	ProductTableName() string

	// CategoryCount returns the total count of categories matching the query options.
	CategoryCount(ctx context.Context, options CategoryQueryInterface) (int64, error)
	// CategoryCreate inserts a new category into the database.
	CategoryCreate(context context.Context, category CategoryInterface) error
	// CategoryDelete permanently deletes a category from the database.
	CategoryDelete(context context.Context, category CategoryInterface) error
	// CategoryDeleteByID permanently deletes a category by its ID.
	CategoryDeleteByID(context context.Context, categoryID string) error
	// CategoryFindByID retrieves a category by its unique ID.
	CategoryFindByID(context context.Context, categoryID string) (CategoryInterface, error)
	// CategoryList retrieves a list of categories matching the query options.
	CategoryList(context context.Context, options CategoryQueryInterface) ([]CategoryInterface, error)
	// CategorySoftDelete soft deletes a category by setting the deleted timestamp.
	CategorySoftDelete(context context.Context, category CategoryInterface) error
	// CategorySoftDeleteByID soft deletes a category by its ID.
	CategorySoftDeleteByID(context context.Context, categoryID string) error
	// CategoryUpdate updates an existing category in the database.
	CategoryUpdate(contxt context.Context, category CategoryInterface) error

	// DiscountCount returns the total count of discounts matching the query options.
	DiscountCount(ctx context.Context, options DiscountQueryInterface) (int64, error)
	// DiscountCreate inserts a new discount into the database.
	DiscountCreate(ctx context.Context, discount DiscountInterface) error
	// DiscountDelete permanently deletes a discount from the database.
	DiscountDelete(ctx context.Context, discount DiscountInterface) error
	// DiscountDeleteByID permanently deletes a discount by its ID.
	DiscountDeleteByID(ctx context.Context, discountID string) error
	// DiscountFindByID retrieves a discount by its unique ID.
	DiscountFindByID(ctx context.Context, discountID string) (DiscountInterface, error)
	// DiscountFindByCode retrieves a discount by its unique code.
	DiscountFindByCode(ctx context.Context, code string) (DiscountInterface, error)
	// DiscountList retrieves a list of discounts matching the query options.
	DiscountList(ctx context.Context, options DiscountQueryInterface) ([]DiscountInterface, error)
	// DiscountSoftDelete soft deletes a discount by setting the deleted timestamp.
	DiscountSoftDelete(ctx context.Context, discount DiscountInterface) error
	// DiscountSoftDeleteByID soft deletes a discount by its ID.
	DiscountSoftDeleteByID(ctx context.Context, discountID string) error
	// DiscountUpdate updates an existing discount in the database.
	DiscountUpdate(ctx context.Context, discount DiscountInterface) error

	// MediaCount returns the total count of media matching the query options.
	MediaCount(ctx context.Context, options MediaQueryInterface) (int64, error)
	// MediaCreate inserts a new media into the database.
	MediaCreate(ctx context.Context, media MediaInterface) error
	// MediaDelete permanently deletes a media from the database.
	MediaDelete(ctx context.Context, media MediaInterface) error
	// MediaDeleteByID permanently deletes a media by its ID.
	MediaDeleteByID(ctx context.Context, mediaID string) error
	// MediaFindByID retrieves a media by its unique ID.
	MediaFindByID(ctx context.Context, mediaID string) (MediaInterface, error)
	// MediaList retrieves a list of media matching the query options.
	MediaList(ctx context.Context, options MediaQueryInterface) ([]MediaInterface, error)
	// MediaSoftDelete soft deletes a media by setting the deleted timestamp.
	MediaSoftDelete(ctx context.Context, media MediaInterface) error
	// MediaSoftDeleteByID soft deletes a media by its ID.
	MediaSoftDeleteByID(ctx context.Context, mediaID string) error
	// MediaUpdate updates an existing media in the database.
	MediaUpdate(ctx context.Context, media MediaInterface) error

	// OrderCount returns the total count of orders matching the query options.
	OrderCount(ctx context.Context, options OrderQueryInterface) (int64, error)
	// OrderCreate inserts a new order into the database.
	OrderCreate(ctx context.Context, order OrderInterface) error
	// OrderDelete permanently deletes an order from the database.
	OrderDelete(ctx context.Context, order OrderInterface) error
	// OrderDeleteByID permanently deletes an order by its ID.
	OrderDeleteByID(ctx context.Context, id string) error
	// OrderFindByID retrieves an order by its unique ID.
	OrderFindByID(ctx context.Context, id string) (OrderInterface, error)
	// OrderList retrieves a list of orders matching the query options.
	OrderList(ctx context.Context, options OrderQueryInterface) ([]OrderInterface, error)
	// OrderSoftDelete soft deletes an order by setting the deleted timestamp.
	OrderSoftDelete(ctx context.Context, order OrderInterface) error
	// OrderSoftDeleteByID soft deletes an order by its ID.
	OrderSoftDeleteByID(ctx context.Context, id string) error
	// OrderUpdate updates an existing order in the database.
	OrderUpdate(ctx context.Context, order OrderInterface) error

	// OrderLineItemCount returns the total count of line items matching the query options.
	OrderLineItemCount(ctx context.Context, options OrderLineItemQueryInterface) (int64, error)
	// OrderLineItemCreate inserts a new line item into the database.
	OrderLineItemCreate(ctx context.Context, orderLineItem OrderLineItemInterface) error
	// OrderLineItemDelete permanently deletes a line item from the database.
	OrderLineItemDelete(ctx context.Context, orderLineItem OrderLineItemInterface) error
	// OrderLineItemDeleteByID permanently deletes a line item by its ID.
	OrderLineItemDeleteByID(ctx context.Context, id string) error
	// OrderLineItemFindByID retrieves a line item by its unique ID.
	OrderLineItemFindByID(ctx context.Context, id string) (OrderLineItemInterface, error)
	// OrderLineItemList retrieves a list of line items matching the query options.
	OrderLineItemList(ctx context.Context, options OrderLineItemQueryInterface) ([]OrderLineItemInterface, error)
	// OrderLineItemSoftDelete soft deletes a line item by setting the deleted timestamp.
	OrderLineItemSoftDelete(ctx context.Context, orderLineItem OrderLineItemInterface) error
	// OrderLineItemSoftDeleteByID soft deletes a line item by its ID.
	OrderLineItemSoftDeleteByID(ctx context.Context, id string) error
	// OrderLineItemUpdate updates an existing line item in the database.
	OrderLineItemUpdate(ctx context.Context, orderLineItem OrderLineItemInterface) error

	// ProductCount returns the total count of products matching the query options.
	ProductCount(ctx context.Context, options ProductQueryInterface) (int64, error)
	// ProductCreate inserts a new product into the database.
	ProductCreate(ctx context.Context, product ProductInterface) error
	// ProductDelete permanently deletes a product from the database.
	ProductDelete(ctx context.Context, product ProductInterface) error
	// ProductDeleteByID permanently deletes a product by its ID.
	ProductDeleteByID(ctx context.Context, productID string) error
	// ProductFindByID retrieves a product by its unique ID.
	ProductFindByID(ctx context.Context, productID string) (ProductInterface, error)
	// ProductList retrieves a list of products matching the query options.
	ProductList(ctx context.Context, options ProductQueryInterface) ([]ProductInterface, error)
	// ProductSoftDelete soft deletes a product by setting the deleted timestamp.
	ProductSoftDelete(ctx context.Context, product ProductInterface) error
	// ProductSoftDeleteByID soft deletes a product by its ID.
	ProductSoftDeleteByID(ctx context.Context, productID string) error
	// ProductUpdate updates an existing product in the database.
	ProductUpdate(ctx context.Context, product ProductInterface) error

	// ProductVariantList retrieves all variants for a parent product.
	ProductVariantList(ctx context.Context, parentID string) ([]ProductInterface, error)
	// ProductIsParent checks if a product is a parent (has variants).
	ProductIsParent(ctx context.Context, productID string) (bool, error)
	// ProductGetParent retrieves the parent product for a variant.
	ProductGetParent(ctx context.Context, productID string) (ProductInterface, error)
}

StoreInterface defines the contract for the shop store database operations. Provides CRUD operations, soft deletion, counting, listing with pagination, and variant management for all entity types (categories, discounts, media, orders, products).

type VariantMatrixSchema added in v1.10.0

type VariantMatrixSchema struct {
	Name     string   `json:"name"`              // "color", "size"
	Required bool     `json:"required"`          // must variant have this?
	Options  []string `json:"options,omitempty"` // allowed values (optional)
}

VariantMatrixSchema defines a single dimension for product variants. Used to define variant attributes like color, size, material, etc. Supports optional predefined options and required/optional flags.

Jump to

Keyboard shortcuts

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