result

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package result provides result types for AQL query execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExcelFormatter

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

ExcelFormatter formats query results as Excel files.

func NewExcelFormatter

func NewExcelFormatter() *ExcelFormatter

NewExcelFormatter creates a new Excel formatter.

func (*ExcelFormatter) FormatMultiSheet

func (f *ExcelFormatter) FormatMultiSheet(path string, sheets map[string]*Result) error

FormatMultiSheet writes multiple results to an Excel file with multiple sheets.

func (*ExcelFormatter) FormatToFile

func (f *ExcelFormatter) FormatToFile(path string, result *Result) error

FormatToFile writes the result to an Excel file.

func (*ExcelFormatter) WithFields

func (f *ExcelFormatter) WithFields(fields []string) *ExcelFormatter

WithFields sets specific fields to output.

type ExecutionStats

type ExecutionStats struct {
	// ExecutionTime is the total execution time.
	ExecutionTime int64 // milliseconds

	// APICallCount is the number of API calls made.
	APICallCount int

	// RecordsFetched is the total number of records fetched from API.
	RecordsFetched int

	// RecordsReturned is the number of records in the final result.
	RecordsReturned int

	// CacheHit indicates if the result was served from cache.
	CacheHit bool

	// FiltersPushed is the number of filters pushed to the API.
	FiltersPushed int

	// ClientFilters is the number of filters applied client-side.
	ClientFilters int
}

ExecutionStats contains query execution statistics.

type Format

type Format string

Format represents an output format.

const (
	FormatTable    Format = "table"
	FormatJSON     Format = "json"
	FormatCSV      Format = "csv"
	FormatMarkdown Format = "markdown"
	FormatYAML     Format = "yaml"
	FormatHTML     Format = "html"
	FormatExcel    Format = "xlsx"
)

Output formats.

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat parses a format string.

func (Format) IsFileFormat

func (f Format) IsFileFormat() bool

IsFileFormat returns true if the format requires writing to a file.

type Formatter

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

Formatter formats query results for output.

func NewFormatter

func NewFormatter(format Format) *Formatter

NewFormatter creates a new formatter with the given format.

func (*Formatter) Format

func (f *Formatter) Format(w io.Writer, result *Result) error

Format formats the result and writes to the writer.

func (*Formatter) WithFields

func (f *Formatter) WithFields(fields []string) *Formatter

WithFields sets specific fields to output.

type Metadata

type Metadata struct {
	// TotalCount is the total number of matching records (before LIMIT).
	TotalCount int

	// ExecutionTimeMs is the query execution time in milliseconds.
	ExecutionTimeMs int64

	// IsTruncated indicates if results were truncated due to LIMIT.
	IsTruncated bool
}

Metadata contains optional result metadata.

type Record

type Record map[string]any

Record represents a single result row as a map of field names to values.

func (Record) CustomFieldKeys

func (r Record) CustomFieldKeys() []string

CustomFieldKeys returns all custom field keys (without the "custom." prefix).

func (Record) Get

func (r Record) Get(field string) any

Get returns the value for a field, or nil if not found. Supports custom field lookup using "custom.fieldname" syntax.

func (Record) GetInt

func (r Record) GetInt(field string) int

GetInt returns the int value for a field, or 0 if not found.

func (Record) GetString

func (r Record) GetString(field string) string

GetString returns the string value for a field, or empty string if not found.

func (Record) HasCustomFields

func (r Record) HasCustomFields() bool

HasCustomFields returns true if the record has any custom fields.

func (Record) Keys

func (r Record) Keys() []string

Keys returns all field names in the record.

func (Record) SetCustomField

func (r Record) SetCustomField(key string, value any)

SetCustomField sets a custom field value using the "custom.key" format.

type Result

type Result struct {
	// Entity is the entity type that was queried.
	Entity ast.EntityType

	// Records contains the query results.
	Records []Record

	// Metadata contains optional result metadata.
	Metadata Metadata

	// Stats contains execution statistics (optional).
	Stats *ExecutionStats
}

Result represents the result of an AQL query execution.

func (*Result) AllFields

func (r *Result) AllFields() []string

AllFields returns all unique field names across all records.

func (*Result) Count

func (r *Result) Count() int

Count returns the number of records in the result.

func (*Result) First

func (r *Result) First() Record

First returns the first record, or nil if empty.

func (*Result) IsEmpty

func (r *Result) IsEmpty() bool

IsEmpty returns true if there are no records.

Jump to

Keyboard shortcuts

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