aggregate

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateClient

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

AggregateClient handles ServiceNow Aggregate API operations

func NewAggregateClient

func NewAggregateClient(client *core.Client, tableName string) *AggregateClient

NewAggregateClient creates a new aggregate client for a specific table

func (*AggregateClient) AvgField

func (ac *AggregateClient) AvgField(field string, qb *query.QueryBuilder) (float64, error)

AvgField returns the average of a numeric field

func (*AggregateClient) AvgFieldWithContext

func (ac *AggregateClient) AvgFieldWithContext(ctx context.Context, field string, qb *query.QueryBuilder) (float64, error)

AvgFieldWithContext returns the average of a numeric field with context support

func (*AggregateClient) CountRecords

func (ac *AggregateClient) CountRecords(qb *query.QueryBuilder) (int, error)

CountRecords returns the total number of records matching the query

func (*AggregateClient) CountRecordsWithContext

func (ac *AggregateClient) CountRecordsWithContext(ctx context.Context, qb *query.QueryBuilder) (int, error)

CountRecordsWithContext returns the total number of records with context support

func (*AggregateClient) MinMaxField

func (ac *AggregateClient) MinMaxField(field string, qb *query.QueryBuilder) (min, max float64, err error)

MinMaxField returns both minimum and maximum values of a field

func (*AggregateClient) MinMaxFieldWithContext

func (ac *AggregateClient) MinMaxFieldWithContext(ctx context.Context, field string, qb *query.QueryBuilder) (min, max float64, err error)

MinMaxFieldWithContext returns both minimum and maximum values with context support

func (*AggregateClient) NewQuery

func (ac *AggregateClient) NewQuery() *AggregateQuery

NewQuery creates a new aggregate query for the table

func (*AggregateClient) SumField

func (ac *AggregateClient) SumField(field string, qb *query.QueryBuilder) (float64, error)

SumField returns the sum of a numeric field

func (*AggregateClient) SumFieldWithContext

func (ac *AggregateClient) SumFieldWithContext(ctx context.Context, field string, qb *query.QueryBuilder) (float64, error)

SumFieldWithContext returns the sum of a numeric field with context support

type AggregateField

type AggregateField struct {
	Field string        `json:"field"`
	Type  AggregateType `json:"type"`
	Alias string        `json:"alias,omitempty"`
}

AggregateField represents a field to aggregate

type AggregateQuery

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

AggregateQuery represents a complete aggregate query

func (*AggregateQuery) Aggregate

func (aq *AggregateQuery) Aggregate(field string, aggType AggregateType, alias string) *AggregateQuery

Aggregate adds an aggregate field to the query

func (*AggregateQuery) And

func (aq *AggregateQuery) And() *AggregateQuery

And adds an AND condition

func (*AggregateQuery) Avg

func (aq *AggregateQuery) Avg(field string, alias string) *AggregateQuery

Avg adds an AVG aggregation

func (*AggregateQuery) BuildParams

func (aq *AggregateQuery) BuildParams() map[string]string

BuildParams constructs the query parameters for the aggregate request

func (*AggregateQuery) Contains

func (aq *AggregateQuery) Contains(field string, value interface{}) *AggregateQuery

Contains adds a contains condition

func (*AggregateQuery) Count

func (aq *AggregateQuery) Count(field string, alias string) *AggregateQuery

Count adds a COUNT aggregation

func (*AggregateQuery) CountAll

func (aq *AggregateQuery) CountAll(alias string) *AggregateQuery

CountAll adds a COUNT(*) aggregation

func (*AggregateQuery) Equals

func (aq *AggregateQuery) Equals(field string, value interface{}) *AggregateQuery

Equals adds an equality condition

func (*AggregateQuery) Execute

func (aq *AggregateQuery) Execute() (*AggregateResult, error)

Execute runs the aggregate query

func (*AggregateQuery) ExecuteWithContext

func (aq *AggregateQuery) ExecuteWithContext(ctx context.Context) (*AggregateResult, error)

ExecuteWithContext runs the aggregate query with context support

func (*AggregateQuery) GroupByField

func (aq *AggregateQuery) GroupByField(field string, alias string) *AggregateQuery

GroupByField adds a GROUP BY field

func (*AggregateQuery) Having

func (aq *AggregateQuery) Having(condition string) *AggregateQuery

Having adds a HAVING condition for aggregate results

func (*AggregateQuery) Limit

func (aq *AggregateQuery) Limit(limit int) *AggregateQuery

Limit sets the maximum number of aggregate results

func (*AggregateQuery) Max

func (aq *AggregateQuery) Max(field string, alias string) *AggregateQuery

Max adds a MAX aggregation

func (*AggregateQuery) Min

func (aq *AggregateQuery) Min(field string, alias string) *AggregateQuery

Min adds a MIN aggregation

func (*AggregateQuery) Offset

func (aq *AggregateQuery) Offset(offset int) *AggregateQuery

Offset sets the number of aggregate results to skip

func (*AggregateQuery) Or

func (aq *AggregateQuery) Or() *AggregateQuery

Or adds an OR condition

func (*AggregateQuery) OrderBy

func (aq *AggregateQuery) OrderBy(field string, direction query.OrderDirection) *AggregateQuery

OrderBy adds ordering to the aggregate results

func (*AggregateQuery) OrderByAsc

func (aq *AggregateQuery) OrderByAsc(field string) *AggregateQuery

OrderByAsc adds ascending order

func (*AggregateQuery) OrderByDesc

func (aq *AggregateQuery) OrderByDesc(field string) *AggregateQuery

OrderByDesc adds descending order

func (*AggregateQuery) StdDev

func (aq *AggregateQuery) StdDev(field string, alias string) *AggregateQuery

StdDev adds a STDDEV aggregation

func (*AggregateQuery) Sum

func (aq *AggregateQuery) Sum(field string, alias string) *AggregateQuery

Sum adds a SUM aggregation

func (*AggregateQuery) Variance

func (aq *AggregateQuery) Variance(field string, alias string) *AggregateQuery

Variance adds a VARIANCE aggregation

func (*AggregateQuery) Where

func (aq *AggregateQuery) Where(field string, operator query.Operator, value interface{}) *AggregateQuery

Where adds a WHERE condition using the query builder

type AggregateResult

type AggregateResult struct {
	Stats  map[string]interface{}   `json:"stats"`
	Result []map[string]interface{} `json:"result"`
}

AggregateResult represents the result of an aggregate query

type AggregateType

type AggregateType string

AggregateType represents the type of aggregation

const (
	Count    AggregateType = "COUNT"
	Sum      AggregateType = "SUM"
	Avg      AggregateType = "AVG"
	Min      AggregateType = "MIN"
	Max      AggregateType = "MAX"
	StdDev   AggregateType = "STDDEV"
	Variance AggregateType = "VARIANCE"
)

type GroupBy

type GroupBy struct {
	Field string `json:"field"`
	Alias string `json:"alias,omitempty"`
}

GroupBy represents a field to group by

Jump to

Keyboard shortcuts

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