Documentation
¶
Index ¶
- type AggregationQueryImpl
- func (q *AggregationQueryImpl) Avg(fieldName string, alias string) types.AggregationQuery
- func (q *AggregationQueryImpl) BuildSQL() (string, []any, error)
- func (q *AggregationQueryImpl) Count(fieldName string, alias string) types.AggregationQuery
- func (q *AggregationQueryImpl) CountAll(alias string) types.AggregationQuery
- func (q *AggregationQueryImpl) Exec(ctx context.Context, dest any) error
- func (q *AggregationQueryImpl) GetModelName() string
- func (q *AggregationQueryImpl) GroupBy(fieldNames ...string) types.AggregationQuery
- func (q *AggregationQueryImpl) Having(condition types.Condition) types.AggregationQuery
- func (q *AggregationQueryImpl) Limit(limit int) types.AggregationQuery
- func (q *AggregationQueryImpl) Max(fieldName string, alias string) types.AggregationQuery
- func (q *AggregationQueryImpl) Min(fieldName string, alias string) types.AggregationQuery
- func (q *AggregationQueryImpl) Offset(offset int) types.AggregationQuery
- func (q *AggregationQueryImpl) OrderBy(fieldName string, direction types.Order) types.AggregationQuery
- func (q *AggregationQueryImpl) OrderByAggregation(aggregationType string, fieldName string, direction types.Order) types.AggregationQuery
- func (q *AggregationQueryImpl) Select(fieldNames ...string) types.AggregationQuery
- func (q *AggregationQueryImpl) Sum(fieldName string, alias string) types.AggregationQuery
- func (q *AggregationQueryImpl) Where(fieldName string) types.FieldCondition
- func (q *AggregationQueryImpl) WhereCondition(condition types.Condition) types.AggregationQuery
- type AtomicOperation
- type ConditionEvaluator
- type DeleteQueryImpl
- func (q *DeleteQueryImpl) BuildSQL() (string, []any, error)
- func (q *DeleteQueryImpl) Exec(ctx context.Context) (types.Result, error)
- func (q *DeleteQueryImpl) GetReturningFields() []string
- func (q *DeleteQueryImpl) GetWhereConditions() []types.Condition
- func (q *DeleteQueryImpl) Returning(fieldNames ...string) types.DeleteQuery
- func (q *DeleteQueryImpl) Where(fieldName string) types.FieldCondition
- func (q *DeleteQueryImpl) WhereCondition(condition types.Condition) types.DeleteQuery
- type HierarchicalScanner
- type IncludeProcessor
- type InsertQueryImpl
- func (q *InsertQueryImpl) BuildSQL() (string, []any, error)
- func (q *InsertQueryImpl) Exec(ctx context.Context) (types.Result, error)
- func (q *InsertQueryImpl) ExecAndReturn(ctx context.Context, dest any) error
- func (q *InsertQueryImpl) OnConflict(action types.ConflictAction) types.InsertQuery
- func (q *InsertQueryImpl) Returning(fieldNames ...string) types.InsertQuery
- func (q *InsertQueryImpl) Values(data ...any) types.InsertQuery
- type JoinBuilder
- func (b *JoinBuilder) AddManyToManyJoin(fromModel string, fromAlias string, relationName string, joinType JoinType) error
- func (b *JoinBuilder) AddNestedRelationJoin(parentAlias string, parentModel string, relationPath []string, ...) error
- func (b *JoinBuilder) AddRelationJoin(fromModel string, fromAlias string, relationName string, joinType JoinType) error
- func (b *JoinBuilder) BuildSQL() string
- func (b *JoinBuilder) GetJoinedTables() []JoinClause
- func (b *JoinBuilder) SetIncludeOptions(includeOptions map[string]*types.IncludeOption)
- type JoinClause
- type JoinInfo
- type JoinType
- type ModelQueryImpl
- func (q *ModelQueryImpl) Aggregate() types.AggregationQuery
- func (q *ModelQueryImpl) Avg(ctx context.Context, fieldName string) (float64, error)
- func (q *ModelQueryImpl) Count(ctx context.Context) (int64, error)
- func (q *ModelQueryImpl) Delete() types.DeleteQuery
- func (q *ModelQueryImpl) Exists(ctx context.Context) (bool, error)
- func (q *ModelQueryImpl) FindFirst(ctx context.Context, dest any) error
- func (q *ModelQueryImpl) FindMany(ctx context.Context, dest any) error
- func (q *ModelQueryImpl) FindUnique(ctx context.Context, dest any) error
- func (q *ModelQueryImpl) GetConditions() []types.Condition
- func (q *ModelQueryImpl) GetDatabase() types.Database
- func (q *ModelQueryImpl) GetFieldMapper() types.FieldMapper
- func (q *ModelQueryImpl) GetGroupBy() []string
- func (q *ModelQueryImpl) GetHaving() types.Condition
- func (q *ModelQueryImpl) GetIncludeOptions() types.IncludeOptions
- func (q *ModelQueryImpl) GetIncludes() []string
- func (q *ModelQueryImpl) GetLimit() *int
- func (q *ModelQueryImpl) GetModelName() string
- func (q *ModelQueryImpl) GetOffset() *int
- func (q *ModelQueryImpl) GetOrderBy() []OrderClause
- func (q *ModelQueryImpl) GroupBy(fieldNames ...string) types.ModelQuery
- func (q *ModelQueryImpl) Having(condition types.Condition) types.ModelQuery
- func (q *ModelQueryImpl) Include(relations ...string) types.ModelQuery
- func (q *ModelQueryImpl) Insert(data any) types.InsertQuery
- func (q *ModelQueryImpl) Limit(limit int) types.ModelQuery
- func (q *ModelQueryImpl) Max(ctx context.Context, fieldName string) (any, error)
- func (q *ModelQueryImpl) Min(ctx context.Context, fieldName string) (any, error)
- func (q *ModelQueryImpl) Offset(offset int) types.ModelQuery
- func (q *ModelQueryImpl) OrderBy(fieldName string, direction types.Order) types.ModelQuery
- func (q *ModelQueryImpl) Select(fields ...string) types.SelectQuery
- func (q *ModelQueryImpl) Sum(ctx context.Context, fieldName string) (float64, error)
- func (q *ModelQueryImpl) Update(data any) types.UpdateQuery
- func (q *ModelQueryImpl) Where(fieldName string) types.FieldCondition
- func (q *ModelQueryImpl) WhereCondition(condition types.Condition) types.ModelQuery
- func (q *ModelQueryImpl) WhereRaw(sql string, args ...any) types.ModelQuery
- func (q *ModelQueryImpl) With(relations ...string) types.ModelQuery
- type OrderClause
- type RawQueryImpl
- type RecordNode
- type RelationScanner
- type SelectQueryImpl
- func (q *SelectQueryImpl) BuildSQL() (string, []any, error)
- func (q *SelectQueryImpl) Count(ctx context.Context) (int64, error)
- func (q *SelectQueryImpl) Distinct() types.SelectQuery
- func (q *SelectQueryImpl) DistinctOn(fieldNames ...string) types.SelectQuery
- func (q *SelectQueryImpl) FindFirst(ctx context.Context, dest any) error
- func (q *SelectQueryImpl) FindMany(ctx context.Context, dest any) error
- func (q *SelectQueryImpl) GetConditions() []types.Condition
- func (q *SelectQueryImpl) GetDistinct() bool
- func (q *SelectQueryImpl) GetDistinctOn() []string
- func (q *SelectQueryImpl) GetGroupBy() []string
- func (q *SelectQueryImpl) GetHaving() types.Condition
- func (q *SelectQueryImpl) GetLimit() int
- func (q *SelectQueryImpl) GetOffset() int
- func (q *SelectQueryImpl) GetOrderBy() []types.OrderByClause
- func (q *SelectQueryImpl) GetSelectedFields() []string
- func (q *SelectQueryImpl) GroupBy(fieldNames ...string) types.SelectQuery
- func (q *SelectQueryImpl) Having(condition types.Condition) types.SelectQuery
- func (q *SelectQueryImpl) Include(relations ...string) types.SelectQuery
- func (q *SelectQueryImpl) IncludeWithOptions(path string, opt *types.IncludeOption) types.SelectQuery
- func (q *SelectQueryImpl) Limit(limit int) types.SelectQuery
- func (q *SelectQueryImpl) Offset(offset int) types.SelectQuery
- func (q *SelectQueryImpl) OrderBy(fieldName string, direction types.Order) types.SelectQuery
- func (q *SelectQueryImpl) Where(fieldName string) types.FieldCondition
- func (q *SelectQueryImpl) WhereCondition(condition types.Condition) types.SelectQuery
- type UpdateQueryImpl
- func (q *UpdateQueryImpl) BuildSQL() (string, []any, error)
- func (q *UpdateQueryImpl) Decrement(fieldName string, value int64) types.UpdateQuery
- func (q *UpdateQueryImpl) Exec(ctx context.Context) (types.Result, error)
- func (q *UpdateQueryImpl) ExecAndReturn(ctx context.Context, dest any) error
- func (q *UpdateQueryImpl) GetAtomicOps() map[string]AtomicOperation
- func (q *UpdateQueryImpl) GetReturningFields() []string
- func (q *UpdateQueryImpl) GetSetData() map[string]any
- func (q *UpdateQueryImpl) GetWhereConditions() []types.Condition
- func (q *UpdateQueryImpl) Increment(fieldName string, value int64) types.UpdateQuery
- func (q *UpdateQueryImpl) Returning(fieldNames ...string) types.UpdateQuery
- func (q *UpdateQueryImpl) Set(data any) types.UpdateQuery
- func (q *UpdateQueryImpl) Where(fieldName string) types.FieldCondition
- func (q *UpdateQueryImpl) WhereCondition(condition types.Condition) types.UpdateQuery
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregationQueryImpl ¶
type AggregationQueryImpl struct {
*ModelQueryImpl
// contains filtered or unexported fields
}
AggregationQueryImpl implements the AggregationQuery interface
func NewAggregationQuery ¶
func NewAggregationQuery(baseQuery *ModelQueryImpl) *AggregationQueryImpl
NewAggregationQuery creates a new aggregation query
func (*AggregationQueryImpl) Avg ¶
func (q *AggregationQueryImpl) Avg(fieldName string, alias string) types.AggregationQuery
Avg adds an AVG aggregation
func (*AggregationQueryImpl) BuildSQL ¶
func (q *AggregationQueryImpl) BuildSQL() (string, []any, error)
BuildSQL builds the SQL query
func (*AggregationQueryImpl) Count ¶
func (q *AggregationQueryImpl) Count(fieldName string, alias string) types.AggregationQuery
Count adds a COUNT aggregation
func (*AggregationQueryImpl) CountAll ¶
func (q *AggregationQueryImpl) CountAll(alias string) types.AggregationQuery
CountAll adds a COUNT(*) aggregation
func (*AggregationQueryImpl) Exec ¶
func (q *AggregationQueryImpl) Exec(ctx context.Context, dest any) error
Exec executes the aggregation query
func (*AggregationQueryImpl) GetModelName ¶
func (q *AggregationQueryImpl) GetModelName() string
GetModelName returns the model name
func (*AggregationQueryImpl) GroupBy ¶
func (q *AggregationQueryImpl) GroupBy(fieldNames ...string) types.AggregationQuery
GroupBy adds grouping fields
func (*AggregationQueryImpl) Having ¶
func (q *AggregationQueryImpl) Having(condition types.Condition) types.AggregationQuery
Having adds having condition
func (*AggregationQueryImpl) Limit ¶
func (q *AggregationQueryImpl) Limit(limit int) types.AggregationQuery
Limit sets the limit
func (*AggregationQueryImpl) Max ¶
func (q *AggregationQueryImpl) Max(fieldName string, alias string) types.AggregationQuery
Max adds a MAX aggregation
func (*AggregationQueryImpl) Min ¶
func (q *AggregationQueryImpl) Min(fieldName string, alias string) types.AggregationQuery
Min adds a MIN aggregation
func (*AggregationQueryImpl) Offset ¶
func (q *AggregationQueryImpl) Offset(offset int) types.AggregationQuery
Offset sets the offset
func (*AggregationQueryImpl) OrderBy ¶
func (q *AggregationQueryImpl) OrderBy(fieldName string, direction types.Order) types.AggregationQuery
OrderBy adds ordering by a field
func (*AggregationQueryImpl) OrderByAggregation ¶
func (q *AggregationQueryImpl) OrderByAggregation(aggregationType string, fieldName string, direction types.Order) types.AggregationQuery
OrderByAggregation adds ordering by an aggregation result
func (*AggregationQueryImpl) Select ¶
func (q *AggregationQueryImpl) Select(fieldNames ...string) types.AggregationQuery
Select adds grouped fields to select
func (*AggregationQueryImpl) Sum ¶
func (q *AggregationQueryImpl) Sum(fieldName string, alias string) types.AggregationQuery
Sum adds a SUM aggregation
func (*AggregationQueryImpl) Where ¶
func (q *AggregationQueryImpl) Where(fieldName string) types.FieldCondition
Where adds a field condition
func (*AggregationQueryImpl) WhereCondition ¶
func (q *AggregationQueryImpl) WhereCondition(condition types.Condition) types.AggregationQuery
WhereCondition adds a condition
type AtomicOperation ¶
type ConditionEvaluator ¶
type ConditionEvaluator struct {
// contains filtered or unexported fields
}
ConditionEvaluator evaluates conditions against in-memory records
func NewConditionEvaluator ¶
func NewConditionEvaluator(fieldMapper types.FieldMapper) *ConditionEvaluator
NewConditionEvaluator creates a new condition evaluator
type DeleteQueryImpl ¶
type DeleteQueryImpl struct {
*ModelQueryImpl
// contains filtered or unexported fields
}
DeleteQueryImpl implements the DeleteQuery interface
func NewDeleteQuery ¶
func NewDeleteQuery(baseQuery *ModelQueryImpl) *DeleteQueryImpl
NewDeleteQuery creates a new delete query
func (*DeleteQueryImpl) BuildSQL ¶
func (q *DeleteQueryImpl) BuildSQL() (string, []any, error)
BuildSQL builds the delete SQL query
func (*DeleteQueryImpl) GetReturningFields ¶
func (q *DeleteQueryImpl) GetReturningFields() []string
GetReturningFields returns the returning fields
func (*DeleteQueryImpl) GetWhereConditions ¶
func (q *DeleteQueryImpl) GetWhereConditions() []types.Condition
GetWhereConditions returns the where conditions
func (*DeleteQueryImpl) Returning ¶
func (q *DeleteQueryImpl) Returning(fieldNames ...string) types.DeleteQuery
Returning sets fields to return after delete
func (*DeleteQueryImpl) Where ¶
func (q *DeleteQueryImpl) Where(fieldName string) types.FieldCondition
Where adds a field condition to the delete query
func (*DeleteQueryImpl) WhereCondition ¶
func (q *DeleteQueryImpl) WhereCondition(condition types.Condition) types.DeleteQuery
WhereCondition adds a condition to the delete query
type HierarchicalScanner ¶
type HierarchicalScanner struct {
// contains filtered or unexported fields
}
HierarchicalScanner handles scanning results with nested relations
func NewHierarchicalScanner ¶
func NewHierarchicalScanner(mainSchema *schema.Schema, mainAlias string) *HierarchicalScanner
NewHierarchicalScanner creates a new hierarchical scanner
func (*HierarchicalScanner) AddJoinedTable ¶
func (hs *HierarchicalScanner) AddJoinedTable(alias string, schema *schema.Schema, relation *schema.Relation, relationName string, parentAlias string, path string)
AddJoinedTable adds information about a joined table with its parent
func (*HierarchicalScanner) ScanRowsWithRelations ¶
func (hs *HierarchicalScanner) ScanRowsWithRelations(rows *sql.Rows, dest any) error
ScanRowsWithRelations scans rows with nested relations
func (*HierarchicalScanner) SetIncludeProcessor ¶
func (hs *HierarchicalScanner) SetIncludeProcessor(processor *IncludeProcessor)
SetIncludeProcessor sets the include processor for filtering and field selection
type IncludeProcessor ¶
type IncludeProcessor struct {
// contains filtered or unexported fields
}
IncludeProcessor handles processing of include options for relation loading
func NewIncludeProcessor ¶
func NewIncludeProcessor(database types.Database, fieldMapper types.FieldMapper, includeOptions types.IncludeOptions) *IncludeProcessor
NewIncludeProcessor creates a new include processor
func (*IncludeProcessor) GetSelectFields ¶
func (ip *IncludeProcessor) GetSelectFields(relationPath string, schema *schema.Schema) []string
GetSelectFields returns the fields to select for a given relation path
func (*IncludeProcessor) ProcessRelationData ¶
func (ip *IncludeProcessor) ProcessRelationData(relationPath string, data []map[string]any) []map[string]any
ProcessRelationData filters and processes relation data based on include options
type InsertQueryImpl ¶
type InsertQueryImpl struct {
*ModelQueryImpl
// contains filtered or unexported fields
}
InsertQueryImpl implements the InsertQuery interface
func NewInsertQuery ¶
func NewInsertQuery(baseQuery *ModelQueryImpl, data any) *InsertQueryImpl
NewInsertQuery creates a new insert query
func (*InsertQueryImpl) BuildSQL ¶
func (q *InsertQueryImpl) BuildSQL() (string, []any, error)
BuildSQL builds the insert SQL query
func (*InsertQueryImpl) ExecAndReturn ¶
func (q *InsertQueryImpl) ExecAndReturn(ctx context.Context, dest any) error
ExecAndReturn executes the insert and returns the inserted data
func (*InsertQueryImpl) OnConflict ¶
func (q *InsertQueryImpl) OnConflict(action types.ConflictAction) types.InsertQuery
OnConflict sets the conflict resolution action
func (*InsertQueryImpl) Returning ¶
func (q *InsertQueryImpl) Returning(fieldNames ...string) types.InsertQuery
Returning sets fields to return after insert
func (*InsertQueryImpl) Values ¶
func (q *InsertQueryImpl) Values(data ...any) types.InsertQuery
Values adds more data to insert
type JoinBuilder ¶
type JoinBuilder struct {
// contains filtered or unexported fields
}
JoinBuilder handles building SQL joins from relations
func NewJoinBuilder ¶
func NewJoinBuilder(database types.Database) *JoinBuilder
NewJoinBuilder creates a new join builder
func NewJoinBuilderWithReservedAliases ¶
func NewJoinBuilderWithReservedAliases(database types.Database, reservedAliases ...string) *JoinBuilder
NewJoinBuilderWithReservedAliases creates a new join builder with reserved aliases
func (*JoinBuilder) AddManyToManyJoin ¶
func (b *JoinBuilder) AddManyToManyJoin( fromModel string, fromAlias string, relationName string, joinType JoinType, ) error
AddManyToManyJoin adds joins for a many-to-many relation
func (*JoinBuilder) AddNestedRelationJoin ¶
func (b *JoinBuilder) AddNestedRelationJoin( parentAlias string, parentModel string, relationPath []string, joinType JoinType, ) error
AddNestedRelationJoin adds a nested relation join
func (*JoinBuilder) AddRelationJoin ¶
func (b *JoinBuilder) AddRelationJoin( fromModel string, fromAlias string, relationName string, joinType JoinType, ) error
AddRelationJoin adds a join based on a relation
func (*JoinBuilder) BuildSQL ¶
func (b *JoinBuilder) BuildSQL() string
BuildSQL generates the JOIN SQL clauses
func (*JoinBuilder) GetJoinedTables ¶
func (b *JoinBuilder) GetJoinedTables() []JoinClause
GetJoinedTables returns information about all joined tables
func (*JoinBuilder) SetIncludeOptions ¶
func (b *JoinBuilder) SetIncludeOptions(includeOptions map[string]*types.IncludeOption)
SetIncludeOptions sets include options for specific relation paths
type JoinClause ¶
type JoinClause struct {
Type JoinType
Table string // Table to join
Alias string // Table alias
Condition string // Join condition
Schema *schema.Schema // Schema of joined table
Relation *schema.Relation // Relation definition
RelationName string // Name of the relation field (e.g., "posts")
ParentAlias string // Alias of the parent table
RelationPath string // Full relation path (e.g., "posts.comments")
NestedJoins []JoinClause // Nested joins for this table
IncludeOpt *types.IncludeOption // Include options for filtering
}
JoinClause represents a single join operation
type JoinInfo ¶
type JoinInfo struct {
Schema *schema.Schema
Relation *schema.Relation
RelationName string
ParentAlias string // alias of the parent table
Path string // full relation path
}
JoinInfo contains information about a joined table
type ModelQueryImpl ¶
type ModelQueryImpl struct {
// contains filtered or unexported fields
}
ModelQueryImpl implements the ModelQuery interface
func NewModelQuery ¶
func NewModelQuery(modelName string, database types.Database, fieldMapper types.FieldMapper) *ModelQueryImpl
NewModelQuery creates a new model query
func (*ModelQueryImpl) Aggregate ¶
func (q *ModelQueryImpl) Aggregate() types.AggregationQuery
Aggregate creates a new aggregation query
func (*ModelQueryImpl) Count ¶
func (q *ModelQueryImpl) Count(ctx context.Context) (int64, error)
Count returns the count of matching records
func (*ModelQueryImpl) Delete ¶
func (q *ModelQueryImpl) Delete() types.DeleteQuery
Delete creates a new delete query
func (*ModelQueryImpl) Exists ¶
func (q *ModelQueryImpl) Exists(ctx context.Context) (bool, error)
Exists checks if any matching records exist
func (*ModelQueryImpl) FindFirst ¶
func (q *ModelQueryImpl) FindFirst(ctx context.Context, dest any) error
FindFirst executes the query and returns the first result
func (*ModelQueryImpl) FindMany ¶
func (q *ModelQueryImpl) FindMany(ctx context.Context, dest any) error
FindMany executes the query and returns multiple results
func (*ModelQueryImpl) FindUnique ¶
func (q *ModelQueryImpl) FindUnique(ctx context.Context, dest any) error
FindUnique executes the query and returns a single unique result
func (*ModelQueryImpl) GetConditions ¶
func (q *ModelQueryImpl) GetConditions() []types.Condition
GetConditions returns all conditions (for internal use by query builders)
func (*ModelQueryImpl) GetDatabase ¶
func (q *ModelQueryImpl) GetDatabase() types.Database
GetDatabase returns the database (for internal use)
func (*ModelQueryImpl) GetFieldMapper ¶
func (q *ModelQueryImpl) GetFieldMapper() types.FieldMapper
GetFieldMapper returns the field mapper (for internal use)
func (*ModelQueryImpl) GetGroupBy ¶
func (q *ModelQueryImpl) GetGroupBy() []string
GetGroupBy returns group by fields (for internal use)
func (*ModelQueryImpl) GetHaving ¶
func (q *ModelQueryImpl) GetHaving() types.Condition
GetHaving returns having condition (for internal use)
func (*ModelQueryImpl) GetIncludeOptions ¶
func (q *ModelQueryImpl) GetIncludeOptions() types.IncludeOptions
GetIncludeOptions returns include options (for internal use)
func (*ModelQueryImpl) GetIncludes ¶
func (q *ModelQueryImpl) GetIncludes() []string
GetIncludes returns includes (for internal use)
func (*ModelQueryImpl) GetLimit ¶
func (q *ModelQueryImpl) GetLimit() *int
GetLimit returns limit (for internal use)
func (*ModelQueryImpl) GetModelName ¶
func (q *ModelQueryImpl) GetModelName() string
GetModelName returns the model name
func (*ModelQueryImpl) GetOffset ¶
func (q *ModelQueryImpl) GetOffset() *int
GetOffset returns offset (for internal use)
func (*ModelQueryImpl) GetOrderBy ¶
func (q *ModelQueryImpl) GetOrderBy() []OrderClause
GetOrderBy returns order by clauses (for internal use)
func (*ModelQueryImpl) GroupBy ¶
func (q *ModelQueryImpl) GroupBy(fieldNames ...string) types.ModelQuery
GroupBy adds grouping
func (*ModelQueryImpl) Having ¶
func (q *ModelQueryImpl) Having(condition types.Condition) types.ModelQuery
Having adds having condition
func (*ModelQueryImpl) Include ¶
func (q *ModelQueryImpl) Include(relations ...string) types.ModelQuery
Include adds relations to include
func (*ModelQueryImpl) Insert ¶
func (q *ModelQueryImpl) Insert(data any) types.InsertQuery
Insert creates a new insert query
func (*ModelQueryImpl) Limit ¶
func (q *ModelQueryImpl) Limit(limit int) types.ModelQuery
Limit sets the limit
func (*ModelQueryImpl) Offset ¶
func (q *ModelQueryImpl) Offset(offset int) types.ModelQuery
Offset sets the offset
func (*ModelQueryImpl) OrderBy ¶
func (q *ModelQueryImpl) OrderBy(fieldName string, direction types.Order) types.ModelQuery
OrderBy adds ordering
func (*ModelQueryImpl) Select ¶
func (q *ModelQueryImpl) Select(fields ...string) types.SelectQuery
Select creates a new select query
func (*ModelQueryImpl) Update ¶
func (q *ModelQueryImpl) Update(data any) types.UpdateQuery
Update creates a new update query
func (*ModelQueryImpl) Where ¶
func (q *ModelQueryImpl) Where(fieldName string) types.FieldCondition
Where adds a field condition
func (*ModelQueryImpl) WhereCondition ¶
func (q *ModelQueryImpl) WhereCondition(condition types.Condition) types.ModelQuery
WhereCondition adds a condition
func (*ModelQueryImpl) WhereRaw ¶
func (q *ModelQueryImpl) WhereRaw(sql string, args ...any) types.ModelQuery
WhereRaw adds a raw SQL condition
func (*ModelQueryImpl) With ¶
func (q *ModelQueryImpl) With(relations ...string) types.ModelQuery
With is an alias for Include
type OrderClause ¶
type RawQueryImpl ¶
type RawQueryImpl struct {
// contains filtered or unexported fields
}
RawQueryImpl implements the RawQuery interface
func NewRawQuery ¶
func NewRawQuery(database types.Database, sql string, args ...any) *RawQueryImpl
NewRawQuery creates a new raw query
func (*RawQueryImpl) Find ¶
func (q *RawQueryImpl) Find(ctx context.Context, dest any) error
Find executes the raw query and returns multiple results
func (*RawQueryImpl) FindOne ¶
func (q *RawQueryImpl) FindOne(ctx context.Context, dest any) error
FindOne executes the raw query and returns a single result
func (*RawQueryImpl) GetSQL ¶
func (q *RawQueryImpl) GetSQL() (string, []any)
GetSQL returns the SQL and arguments
type RecordNode ¶
type RecordNode struct {
Data map[string]any
Children map[string]map[any]*RecordNode // relationName -> id -> child node
}
RecordNode represents a record with its nested relations
type RelationScanner ¶
type RelationScanner struct {
// contains filtered or unexported fields
}
RelationScanner handles scanning results from queries with joins
func NewRelationScanner ¶
func NewRelationScanner(mainSchema *schema.Schema, mainAlias string) *RelationScanner
NewRelationScanner creates a new relation scanner
func (*RelationScanner) AddJoinedTable ¶
func (rs *RelationScanner) AddJoinedTable(alias string, schema *schema.Schema, relation *schema.Relation, relationName string)
AddJoinedTable adds information about a joined table
func (*RelationScanner) ScanRowsWithRelations ¶
func (rs *RelationScanner) ScanRowsWithRelations(rows *sql.Rows, dest any) error
ScanRowsWithRelations scans rows that include joined data
func (*RelationScanner) SetIncludeProcessor ¶
func (rs *RelationScanner) SetIncludeProcessor(processor *IncludeProcessor)
SetIncludeProcessor sets the include processor for filtering and ordering
type SelectQueryImpl ¶
type SelectQueryImpl struct {
*ModelQueryImpl
// contains filtered or unexported fields
}
SelectQueryImpl implements the SelectQuery interface
func NewSelectQuery ¶
func NewSelectQuery(baseQuery *ModelQueryImpl, fields []string) *SelectQueryImpl
NewSelectQuery creates a new select query
func (*SelectQueryImpl) BuildSQL ¶
func (q *SelectQueryImpl) BuildSQL() (string, []any, error)
BuildSQL builds the SQL query
func (*SelectQueryImpl) Count ¶
func (q *SelectQueryImpl) Count(ctx context.Context) (int64, error)
Count returns the count of matching records
func (*SelectQueryImpl) Distinct ¶
func (q *SelectQueryImpl) Distinct() types.SelectQuery
Distinct enables distinct selection
func (*SelectQueryImpl) DistinctOn ¶
func (q *SelectQueryImpl) DistinctOn(fieldNames ...string) types.SelectQuery
DistinctOn enables distinct selection on specific fields
func (*SelectQueryImpl) FindFirst ¶
func (q *SelectQueryImpl) FindFirst(ctx context.Context, dest any) error
FindFirst executes the query and returns the first result
func (*SelectQueryImpl) FindMany ¶
func (q *SelectQueryImpl) FindMany(ctx context.Context, dest any) error
FindMany executes the query and returns multiple results
func (*SelectQueryImpl) GetConditions ¶
func (q *SelectQueryImpl) GetConditions() []types.Condition
GetConditions returns the conditions
func (*SelectQueryImpl) GetDistinct ¶
func (q *SelectQueryImpl) GetDistinct() bool
GetDistinct returns whether this is a distinct query
func (*SelectQueryImpl) GetDistinctOn ¶
func (q *SelectQueryImpl) GetDistinctOn() []string
GetDistinctOn returns the distinct on fields
func (*SelectQueryImpl) GetGroupBy ¶
func (q *SelectQueryImpl) GetGroupBy() []string
GetGroupBy returns the group by fields
func (*SelectQueryImpl) GetHaving ¶
func (q *SelectQueryImpl) GetHaving() types.Condition
GetHaving returns the having condition
func (*SelectQueryImpl) GetLimit ¶
func (q *SelectQueryImpl) GetLimit() int
GetLimit returns the limit
func (*SelectQueryImpl) GetOffset ¶
func (q *SelectQueryImpl) GetOffset() int
GetOffset returns the offset
func (*SelectQueryImpl) GetOrderBy ¶
func (q *SelectQueryImpl) GetOrderBy() []types.OrderByClause
GetOrderBy returns the order by clauses
func (*SelectQueryImpl) GetSelectedFields ¶
func (q *SelectQueryImpl) GetSelectedFields() []string
GetSelectedFields returns the selected fields
func (*SelectQueryImpl) GroupBy ¶
func (q *SelectQueryImpl) GroupBy(fieldNames ...string) types.SelectQuery
GroupBy adds grouping
func (*SelectQueryImpl) Having ¶
func (q *SelectQueryImpl) Having(condition types.Condition) types.SelectQuery
Having adds having condition
func (*SelectQueryImpl) Include ¶
func (q *SelectQueryImpl) Include(relations ...string) types.SelectQuery
Include adds relations to include
func (*SelectQueryImpl) IncludeWithOptions ¶
func (q *SelectQueryImpl) IncludeWithOptions(path string, opt *types.IncludeOption) types.SelectQuery
IncludeWithOptions adds a relation with specific options
func (*SelectQueryImpl) Limit ¶
func (q *SelectQueryImpl) Limit(limit int) types.SelectQuery
Limit sets the limit
func (*SelectQueryImpl) Offset ¶
func (q *SelectQueryImpl) Offset(offset int) types.SelectQuery
Offset sets the offset
func (*SelectQueryImpl) OrderBy ¶
func (q *SelectQueryImpl) OrderBy(fieldName string, direction types.Order) types.SelectQuery
OrderBy adds ordering
func (*SelectQueryImpl) Where ¶
func (q *SelectQueryImpl) Where(fieldName string) types.FieldCondition
Where adds a field condition to the select query
func (*SelectQueryImpl) WhereCondition ¶
func (q *SelectQueryImpl) WhereCondition(condition types.Condition) types.SelectQuery
WhereCondition adds a condition to the select query
type UpdateQueryImpl ¶
type UpdateQueryImpl struct {
*ModelQueryImpl
// contains filtered or unexported fields
}
UpdateQueryImpl implements the UpdateQuery interface
func NewUpdateQuery ¶
func NewUpdateQuery(baseQuery *ModelQueryImpl, data any) *UpdateQueryImpl
NewUpdateQuery creates a new update query
func (*UpdateQueryImpl) BuildSQL ¶
func (q *UpdateQueryImpl) BuildSQL() (string, []any, error)
BuildSQL builds the update SQL query
func (*UpdateQueryImpl) Decrement ¶
func (q *UpdateQueryImpl) Decrement(fieldName string, value int64) types.UpdateQuery
Decrement adds an atomic decrement operation
func (*UpdateQueryImpl) ExecAndReturn ¶
func (q *UpdateQueryImpl) ExecAndReturn(ctx context.Context, dest any) error
ExecAndReturn executes the update and returns the updated data
func (*UpdateQueryImpl) GetAtomicOps ¶
func (q *UpdateQueryImpl) GetAtomicOps() map[string]AtomicOperation
GetAtomicOps returns the atomic operations
func (*UpdateQueryImpl) GetReturningFields ¶
func (q *UpdateQueryImpl) GetReturningFields() []string
GetReturningFields returns the returning fields
func (*UpdateQueryImpl) GetSetData ¶
func (q *UpdateQueryImpl) GetSetData() map[string]any
GetSetData returns the set data
func (*UpdateQueryImpl) GetWhereConditions ¶
func (q *UpdateQueryImpl) GetWhereConditions() []types.Condition
GetWhereConditions returns the where conditions
func (*UpdateQueryImpl) Increment ¶
func (q *UpdateQueryImpl) Increment(fieldName string, value int64) types.UpdateQuery
Increment adds an atomic increment operation
func (*UpdateQueryImpl) Returning ¶
func (q *UpdateQueryImpl) Returning(fieldNames ...string) types.UpdateQuery
Returning sets fields to return after update
func (*UpdateQueryImpl) Set ¶
func (q *UpdateQueryImpl) Set(data any) types.UpdateQuery
Set sets the data to update
func (*UpdateQueryImpl) Where ¶
func (q *UpdateQueryImpl) Where(fieldName string) types.FieldCondition
Where adds a field condition to the update query
func (*UpdateQueryImpl) WhereCondition ¶
func (q *UpdateQueryImpl) WhereCondition(condition types.Condition) types.UpdateQuery
WhereCondition adds a condition to the update query