Documentation
¶
Index ¶
- type BatchOperation
- type BatchResult
- type CompositeCondition
- type Condition
- type CrossSchemaRequest
- type CursorQueryResult
- type DataRecord
- type EntityIdentifier
- type EntityManager
- type EntityOperation
- type EntityUpdate
- type FilterField
- type FilterType
- type KvCondition
- type Logic
- type OperationError
- type OperationType
- type OrderBy
- type QueryRequest
- type QueryResult
- type Reference
- type ReferenceType
- type SortOrder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchOperation ¶
type BatchOperation struct {
Operations []EntityOperation `json:"operations"`
Atomic bool `json:"atomic"` // Whether to use transactions
}
BatchOperation represents batch entity operations
type BatchResult ¶
type BatchResult struct {
Successful []*DataRecord `json:"successful"`
Failed []OperationError `json:"failed"`
TotalCount int `json:"totalCount"`
Duration int64 `json:"duration"` // microseconds
}
BatchResult represents results from batch operations
type CompositeCondition ¶
--- 3. Composite Condition (Non-Leaf Node) ---
func (*CompositeCondition) IsLeaf ¶
func (c *CompositeCondition) IsLeaf() bool
func (*CompositeCondition) UnmarshalJSON ¶
func (c *CompositeCondition) UnmarshalJSON(data []byte) error
UnmarshalJSON customizes decoding so that nested conditions are turned into the appropriate concrete condition implementations.
type CrossSchemaRequest ¶
type CrossSchemaRequest struct {
SchemaNames []string `json:"schema_names" validate:"required"`
SearchTerm string `json:"search_term" validate:"required"`
Page int `json:"page" validate:"min=1"`
ItemsPerPage int `json:"items_per_page" validate:"min=1,max=100"`
Condition Condition `json:"-"` // Custom unmarshal, can be CompositeCondition or KvCondition
}
CrossSchemaRequest represents a cross-schema search request
func (CrossSchemaRequest) MarshalJSON ¶
func (r CrossSchemaRequest) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for CrossSchemaRequest.
func (*CrossSchemaRequest) UnmarshalJSON ¶
func (r *CrossSchemaRequest) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for CrossSchemaRequest. It allows the Condition field to be either a CompositeCondition or KvCondition.
type CursorQueryResult ¶
type CursorQueryResult struct {
Data []*DataRecord `json:"data"`
NextCursor string `json:"next_cursor,omitempty"`
HasMore bool `json:"has_more"`
ExecutionTime time.Duration `json:"execution_time"`
}
CursorQueryResult represents cursor-based pagination results.
type DataRecord ¶
type EntityIdentifier ¶
type EntityIdentifier struct {
SchemaName string `json:"schemaName"`
RowID uuid.UUID `json:"rowId"`
}
EntityIdentifier identifies an entity for operations
type EntityManager ¶
type EntityManager interface {
// Entity CRUD operations
Create(ctx context.Context, req *EntityOperation) (*DataRecord, error)
Get(ctx context.Context, req *QueryRequest) (*DataRecord, error)
Update(ctx context.Context, req *EntityOperation) (*DataRecord, error)
Delete(ctx context.Context, req *EntityOperation) error
// Query operations
Query(ctx context.Context, req *QueryRequest) (*QueryResult, error)
CrossSchemaSearch(ctx context.Context, req *CrossSchemaRequest) (*QueryResult, error)
// Batch operations
BatchCreate(ctx context.Context, req *BatchOperation) (*BatchResult, error)
BatchUpdate(ctx context.Context, req *BatchOperation) (*BatchResult, error)
BatchDelete(ctx context.Context, req *BatchOperation) (*BatchResult, error)
}
EntityManager provides comprehensive entity and query operations
type EntityOperation ¶
type EntityOperation struct {
EntityIdentifier
Type OperationType `json:"type"`
Data map[string]any `json:"data,omitempty"`
Updates map[string]any `json:"updates,omitempty"`
}
EntityOperation represents CRUD operations
type EntityUpdate ¶
type EntityUpdate struct {
EntityIdentifier
Updates any `json:"updates"`
}
EntityUpdate represents an update operation
type FilterField ¶
type FilterField string
const ( FilterFieldAttributeName FilterField = "attr_name" FilterFieldValueText FilterField = "value_text" FilterFieldValueNumeric FilterField = "value_numeric" FilterFieldRowID FilterField = "row_id" FilterFieldSchemaName FilterField = "schema_name" )
type FilterType ¶
type FilterType string
FilterType defines supported filter operations
const ( FilterEquals FilterType = "equals" FilterNotEquals FilterType = "not_equals" FilterStartsWith FilterType = "starts_with" FilterContains FilterType = "contains" FilterGreaterThan FilterType = "gt" FilterLessThan FilterType = "lt" FilterGreaterEq FilterType = "gte" FilterLessEq FilterType = "lte" FilterIn FilterType = "in" FilterNotIn FilterType = "not_in" )
type KvCondition ¶
--- 4. KvCondition (Leaf Node) ---
func (*KvCondition) IsLeaf ¶
func (kv *KvCondition) IsLeaf() bool
func (*KvCondition) UnmarshalJSON ¶
func (kv *KvCondition) UnmarshalJSON(data []byte) error
UnmarshalJSON ensures short-hand keys are present.
type OperationError ¶
type OperationError struct {
Operation EntityOperation `json:"operation"`
Error string `json:"error"`
Code string `json:"code"`
Details map[string]any `json:"details,omitempty"`
}
OperationError represents an error for a specific operation
type OperationType ¶
type OperationType string
OperationType represents CRUD operations
const ( OperationCreate OperationType = "create" OperationRead OperationType = "read" OperationUpdate OperationType = "update" OperationDelete OperationType = "delete" OperationQuery OperationType = "query" )
type QueryRequest ¶
type QueryRequest struct {
SchemaName string `json:"schema_name" validate:"required"`
Page int `json:"page" validate:"min=1"`
ItemsPerPage int `json:"items_per_page" validate:"min=1,max=100"`
Condition Condition `json:"-"` // Custom unmarshal, can be CompositeCondition or KvCondition
SortBy []string `json:"sort_by,omitempty"`
SortOrder SortOrder `json:"sort_order,omitempty"`
RowID *uuid.UUID `json:"row_id,omitempty"` // For entity-specific operations
}
QueryRequest represents a pagination query request.
func (QueryRequest) MarshalJSON ¶
func (r QueryRequest) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for QueryRequest.
func (*QueryRequest) UnmarshalJSON ¶
func (r *QueryRequest) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for QueryRequest. It allows the Condition field to be either a CompositeCondition or KvCondition.
type QueryResult ¶
type QueryResult struct {
Data []*DataRecord `json:"data"`
TotalRecords int `json:"total_records"`
TotalPages int `json:"total_pages"`
CurrentPage int `json:"current_page"`
ItemsPerPage int `json:"items_per_page"`
HasNext bool `json:"has_next"`
HasPrevious bool `json:"has_previous"`
ExecutionTime time.Duration `json:"execution_time"`
}
QueryResult represents paginated query results.
type Reference ¶
type Reference struct {
SourceSchemaName string `json:"sourceSchemaName"`
SourceRowID uuid.UUID `json:"sourceRowId"`
SourceFieldName string `json:"sourceFieldName"`
TargetSchemaName string `json:"targetSchemaName"`
TargetRowID uuid.UUID `json:"targetRowId"`
ReferenceType ReferenceType `json:"referenceType"`
}
Reference represents a reference from one entity to another
type ReferenceType ¶
type ReferenceType string
ReferenceType represents the type of reference
const ( ReferenceTypeSingle ReferenceType = "single" ReferenceTypeArray ReferenceType = "array" ReferenceTypeNested ReferenceType = "nested" )