dynamicmodel

package
v0.0.0-...-c78e9a6 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: LGPL-2.1 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteOneQuerySchemaBuilder

func DeleteOneQuerySchemaBuilder() *dmodel.ModelSchemaBuilder

func ExistsQuerySchemaBuilder

func ExistsQuerySchemaBuilder() *dmodel.ModelSchemaBuilder

func GetOneQuerySchemaBuilder

func GetOneQuerySchemaBuilder() *dmodel.ModelSchemaBuilder

func InitSubModule

func InitSubModule(params InitParams) error

func ManageAssocsSchemaBuilder

func ManageAssocsSchemaBuilder() *dmodel.ModelSchemaBuilder

func SearchQuerySchemaBuilder

func SearchQuerySchemaBuilder() *dmodel.ModelSchemaBuilder

func SetArchivedCommandSchemaBuilder

func SetArchivedCommandSchemaBuilder() *dmodel.ModelSchemaBuilder

Types

type AfterValidationFunc

type AfterValidationFunc[TDomain any] func(ctx corectx.Context, model TDomain) (TDomain, error)

type BaseRepoGetter

type BaseRepoGetter interface {
	GetBaseRepo() BaseRepository
}

type BaseRepository

type BaseRepository interface {
	// CheckUniqueCollisions returns unique key groups that have collisions. Empty slice means no collisions.
	CheckUniqueCollisions(ctx corectx.Context, data dmodel.DynamicFields) (*OpResult[[][]string], error)
	// DeleteOne deletes a single record by primary key then returns the number of affected rows.
	// If affected rows is 0, the record is not found.
	DeleteOne(ctx corectx.Context, keys dmodel.DynamicFields) (*OpResult[int], error)
	// ManageM2m inserts and/or deletes junction rows for a finalized many-to-many link to dest schema.
	// Source and destination are identified by id.
	ManageM2m(ctx corectx.Context, param RepoManageM2mParam) (*OpResult[int], error)
	Insert(ctx corectx.Context, data dmodel.DynamicFields) (*OpResult[int], error)
	GetOne(ctx corectx.Context, param RepoGetOneParam) (*OpResult[dmodel.DynamicFields], error)
	Search(ctx corectx.Context, param RepoSearchParam) (*OpResult[PagedResultData[dmodel.DynamicFields]], error)
	Update(ctx corectx.Context, data dmodel.DynamicFields) (*OpResult[dmodel.DynamicFields], error)
	Exists(ctx corectx.Context, keys []dmodel.DynamicFields) (*OpResult[RepoExistsResult], error)
	GetSchema() *dmodel.ModelSchema
}

type BeforeValidationFunc

type BeforeValidationFunc[TDomain any] func(ctx corectx.Context, model TDomain) (TDomain, error)

type CreateParam

type CreateParam[
	TDomain any,
	TDomainPtr DynamicModelPtr[TDomain],
] struct {
	// Action name for logging and error messages
	Action         string
	BaseRepoGetter BaseRepoGetter

	// Data to create
	Data dmodel.DynamicModelGetter

	// Optional function to do some processing on the domain model before validation.
	BeforeValidation BeforeValidationFunc[TDomainPtr]

	// Optional function to do some processing on the domain model after validation.
	AfterValidation AfterValidationFunc[TDomainPtr]

	// Optional function for advanced validation (business rules) in addition to built-in schema validation.
	ValidateExtra ValidateExtraFunc[TDomainPtr]
}

type DeleteOneCommand

type DeleteOneCommand struct {
	Id model.Id `json:"id" param:"id"`
}

type DynamicModelPtr

type DynamicModelPtr[TDomain any] interface {
	*TDomain
	dmodel.DynamicModel
}

type ExistsQuery

type ExistsQuery struct {
	Ids []model.Id `json:"ids" param:"ids"`
}

type ExistsResultData

type ExistsResultData struct {
	Existing    []model.Id `json:"existing"`
	NotExisting []model.Id `json:"not_existing"`
}

func (ExistsResultData) Exists

func (this ExistsResultData) Exists(id model.Id) bool

type GetOneQuery

type GetOneQuery struct {
	Id      model.Id `json:"id" param:"id"`
	Columns []string `json:"columns" query:"columns"`
}

type InitParams

type InitParams struct {
	dig.In
}

type MutateResultData

type MutateResultData struct {
	AffectedCount int                 `json:"affected_count"`
	AffectedAt    model.ModelDateTime `json:"affected_at"`
	Etag          model.Etag          `json:"etag,omitempty"`
}

type OpResult

type OpResult[TData any] struct {
	// The result data when success. It is only meaningful if HasData is true and ClientErrors is nil.
	// Otherwise, it could be nil or an empty struct.
	Data TData

	// Contains validation errors, business errors...,
	// or nil if there is no violation.
	ClientErrors ft.ClientErrors

	// Indicates whether "Data" is present (non-zero value: non-empty struct, non-empty array, etc.).
	//
	// If ClientErrors is nil but HasData is false,
	// it means the query is successfull but no data is found.
	HasData bool
}

type PagedResultData

type PagedResultData[T any] struct {
	Items []T `json:"items"`
	Total int `json:"total"`
	Page  int `json:"page"`
	Size  int `json:"size"`
}

type PagingOptions

type PagingOptions struct {
	Page int `json:"page" query:"page"`
	Size int `json:"size" query:"size"`
}

type RepoExistsResult

type RepoExistsResult struct {
	Existing    []dmodel.DynamicFields `json:"existing"`
	NotExisting []dmodel.DynamicFields `json:"not_existing"`
}

RepoExistsResult is the raw batch existence outcome per filter map (same order as input keys).

type RepoGetOneParam

type RepoGetOneParam struct {
	Filter  dmodel.DynamicFields
	Columns []string
}

type RepoM2mAssociation

type RepoM2mAssociation struct {
	SrcKeys  dmodel.DynamicFields
	DestKeys dmodel.DynamicFields
}

RepoM2mAssociation is one row to insert into the M2M junction: source entity keys and peer entity keys.

type RepoManageM2mParam

type RepoManageM2mParam struct {
	DestSchemaName     string
	SrcId              model.Id
	SrcIdFieldForError string
	AssociatedIds      datastructure.Set[model.Id]
	DisassociatedIds   datastructure.Set[model.Id]
}

type RepoSearchParam

type RepoSearchParam struct {
	Graph   *dmodel.SearchGraph
	Columns []string
	Filter  []dmodel.DynamicFields
	Page    int
	Size    int
}

type SearchQuery

type SearchQuery struct {
	Columns []string            `json:"columns" query:"columns"`
	Graph   *dmodel.SearchGraph `json:"graph" query:"graph"`
	Page    int                 `json:"page" query:"page"`
	Size    int                 `json:"size" query:"size"`
}

type SetIsArchivedCommand

type SetIsArchivedCommand struct {
	Id         model.Id   `json:"id" param:"id"`
	Etag       model.Etag `json:"etag" param:"etag"`
	IsArchived *bool      `json:"is_archived" param:"is_archived"` // Pointer to trigger missing field error
}

type ToDomainModelFunc

type ToDomainModelFunc[TDomain any] func(data dmodel.DynamicFields) TDomain

type Validatable

type Validatable interface {
	Validate() ft.ClientErrors
}

type ValidateExtraFunc

type ValidateExtraFunc[TDomain any] func(ctx corectx.Context, model TDomain, vErrs *ft.ClientErrors) error

type ValidationFlow

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

func StartValidationFlow

func StartValidationFlow(startWith ...Validatable) *ValidationFlow

func (*ValidationFlow) End

func (this *ValidationFlow) End() (ft.ClientErrors, error)

func (*ValidationFlow) Start

func (this *ValidationFlow) Start() *ValidationFlow

func (*ValidationFlow) Step

func (this *ValidationFlow) Step(fn func(vErrs *ft.ClientErrors) error, ignoreValidationError ...bool) (out *ValidationFlow)

func (*ValidationFlow) StepS

func (this *ValidationFlow) StepS(fn func(vErrs *ft.ClientErrors, stop func()) error, ignoreValidationError ...bool) (out *ValidationFlow)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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