model

package
v0.0.0-...-3e9d567 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2025 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFieldValue

func GetFieldValue(value reflect.Value, fieldPath string) (reflect.Value, bool)

func ParseModelName

func ParseModelName(q interface{}) (string, error)

func SetField

func SetField(item interface{}, fieldName string, value interface{}) error

func ValidateInput

func ValidateInput(q interface{}, operation, structName string) error

Types

type Deconstructed

type Deconstructed struct {
	FieldName  string
	FieldValue interface{}
	FieldType  string
}

type DynamoDBAPI

type DynamoDBAPI interface {
	CreateTable(ctx context.Context, params *dynamodb.CreateTableInput, optFns ...func(*dynamodb.Options)) (*dynamodb.CreateTableOutput, error)
	DescribeTable(ctx context.Context, params *dynamodb.DescribeTableInput, optFns ...func(*dynamodb.Options)) (*dynamodb.DescribeTableOutput, error)
	PutItem(ctx context.Context, params *dynamodb.PutItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error)
	GetItem(ctx context.Context, params *dynamodb.GetItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.GetItemOutput, error)
	DeleteItem(ctx context.Context, params *dynamodb.DeleteItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.DeleteItemOutput, error)
	UpdateItem(ctx context.Context, params *dynamodb.UpdateItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.UpdateItemOutput, error)
	Query(ctx context.Context, params *dynamodb.QueryInput, optFns ...func(*dynamodb.Options)) (*dynamodb.QueryOutput, error)
	Scan(ctx context.Context, params *dynamodb.ScanInput, optFns ...func(*dynamodb.Options)) (*dynamodb.ScanOutput, error)
}

DynamoDBAPI defines the interface for DynamoDB operations This allows us to mock the DynamoDB client for testing

type Model

type Model struct {
	ID        string
	Type      string
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time
}

type Operator

type Operator struct {
	Err               error
	IsWhereChain      bool
	PendingConditions []WhereV4Condition
	IsWhereV4Chain    bool
	// contains filtered or unexported fields
}

func NewMagicModelOperator

func NewMagicModelOperator(ctx context.Context, tableName string, endpoint *string, optFns ...func(options *config.LoadOptions) error) (*Operator, error)

func NewMagicModelOperatorWithClient

func NewMagicModelOperatorWithClient(dbClient DynamoDBAPI, tableName string) *Operator

NewMagicModelOperatorWithClient creates a new operator with a custom DynamoDB client This is useful for testing with mock clients

func (*Operator) All

func (o *Operator) All(q interface{}) *Operator

func (*Operator) Create

func (o *Operator) Create(q interface{}) *Operator

func (*Operator) Delete

func (o *Operator) Delete(q interface{}) *Operator

func (*Operator) Find

func (o *Operator) Find(q interface{}, id string) *Operator

func (*Operator) Save

func (o *Operator) Save(q interface{}) *Operator

func (*Operator) SoftDelete

func (o *Operator) SoftDelete(q interface{}) *Operator

func (*Operator) Update

func (o *Operator) Update(q interface{}, k string, v interface{}) *Operator

func (*Operator) Where

func (o *Operator) Where(q interface{}, k string, v interface{}) *Operator

func (*Operator) WhereV2

func (o *Operator) WhereV2(isChain bool, q interface{}, fieldName string, fieldValue interface{}) *Operator

WhereV2 filters a collection based on a field name and value This is a simpler version of WhereV3 that only supports string comparisons Can be chained with other Where calls when isChain is true

func (*Operator) WhereV3

func (o *Operator) WhereV3(isChain bool, q interface{}, fieldName string, fieldValue interface{}) *Operator

WhereV3 filters a collection based on a field name and value Can be chained with other Where calls when isChain is true

func (*Operator) WhereV4

func (o *Operator) WhereV4(isChain bool, q interface{}, fieldName string, fieldValue interface{}) *Operator

WhereV4 filters a collection based on a field name and value(s) with deferred execution Supports both single values and arrays for OR conditions within the same field Can be chained with other WhereV4 calls when isChain is true

type WhereV4Condition

type WhereV4Condition struct {
	FieldName   string
	FieldValues []interface{}
}

Jump to

Keyboard shortcuts

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