query

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package query provides SOQL query execution and building.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder provides fluent SOQL query building.

func NewBuilder

func NewBuilder(objectType string) *Builder

NewBuilder creates a new query builder.

func (*Builder) Build

func (b *Builder) Build() string

Build generates the SOQL query string.

func (*Builder) ForReference

func (b *Builder) ForReference() *Builder

ForReference adds FOR REFERENCE.

func (*Builder) ForUpdate

func (b *Builder) ForUpdate() *Builder

ForUpdate adds FOR UPDATE.

func (*Builder) ForView

func (b *Builder) ForView() *Builder

ForView adds FOR VIEW.

func (*Builder) GroupBy

func (b *Builder) GroupBy(fields ...string) *Builder

GroupBy adds GROUP BY fields.

func (*Builder) Having

func (b *Builder) Having(condition string) *Builder

Having adds HAVING conditions.

func (*Builder) Limit

func (b *Builder) Limit(limit int) *Builder

Limit sets the result limit.

func (*Builder) Offset

func (b *Builder) Offset(offset int) *Builder

Offset sets the result offset.

func (*Builder) OrderByAsc

func (b *Builder) OrderByAsc(field string) *Builder

OrderByAsc adds ascending ORDER BY.

func (*Builder) OrderByDesc

func (b *Builder) OrderByDesc(field string) *Builder

OrderByDesc adds descending ORDER BY.

func (*Builder) OrderByNullsFirst

func (b *Builder) OrderByNullsFirst(field, direction string) *Builder

OrderByNullsFirst adds NULLS FIRST ordering.

func (*Builder) OrderByNullsLast

func (b *Builder) OrderByNullsLast(field, direction string) *Builder

OrderByNullsLast adds NULLS LAST ordering.

func (*Builder) Select

func (b *Builder) Select(fields ...string) *Builder

Select adds fields to select.

func (*Builder) Where

func (b *Builder) Where(condition string) *Builder

Where adds a WHERE condition.

func (*Builder) WhereEquals

func (b *Builder) WhereEquals(field string, value interface{}) *Builder

WhereEquals adds an equality condition.

func (*Builder) WhereGreaterThan

func (b *Builder) WhereGreaterThan(field string, value interface{}) *Builder

WhereGreaterThan adds a > condition.

func (*Builder) WhereIn

func (b *Builder) WhereIn(field string, values ...interface{}) *Builder

WhereIn adds an IN condition.

func (*Builder) WhereLessThan

func (b *Builder) WhereLessThan(field string, value interface{}) *Builder

WhereLessThan adds a < condition.

func (*Builder) WhereLike

func (b *Builder) WhereLike(field, pattern string) *Builder

WhereLike adds a LIKE condition.

func (*Builder) WhereNotEquals

func (b *Builder) WhereNotEquals(field string, value interface{}) *Builder

WhereNotEquals adds a not-equal condition.

func (*Builder) WhereNotIn

func (b *Builder) WhereNotIn(field string, values ...interface{}) *Builder

WhereNotIn adds a NOT IN condition.

func (*Builder) WhereNotNull

func (b *Builder) WhereNotNull(field string) *Builder

WhereNotNull adds an IS NOT NULL condition.

func (*Builder) WhereNull

func (b *Builder) WhereNull(field string) *Builder

WhereNull adds an IS NULL condition.

type HTTPClient

type HTTPClient interface {
	Get(ctx context.Context, path string) ([]byte, error)
	Post(ctx context.Context, path string, body interface{}) ([]byte, error)
}

HTTPClient interface for dependency injection.

type Result

type Result struct {
	TotalSize      int                      `json:"totalSize"`
	Done           bool                     `json:"done"`
	NextRecordsURL string                   `json:"nextRecordsUrl,omitempty"`
	Records        []*SObject               `json:"-"`
	RawRecords     []map[string]interface{} `json:"records"`
}

Result contains SOQL query results.

func (*Result) HasMore

func (r *Result) HasMore() bool

HasMore returns true if more records are available.

type SObject

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

SObject represents a query result record.

func FromMap

func FromMap(data map[string]interface{}) *SObject

FromMap creates an SObject from a map.

func (*SObject) Get

func (s *SObject) Get(key string) interface{}

Get returns a field value.

func (*SObject) ID

func (s *SObject) ID() string

ID returns the record ID.

func (*SObject) StringField

func (s *SObject) StringField(key string) string

StringField returns a field as string.

func (*SObject) ToMap

func (s *SObject) ToMap() map[string]interface{}

ToMap returns the record as a map.

type Service

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

Service provides SOQL query operations.

func NewService

func NewService(client HTTPClient, apiVersion string) *Service

NewService creates a new Query service.

func (*Service) Execute

func (s *Service) Execute(ctx context.Context, query string) (*Result, error)

Execute runs a SOQL query.

func (*Service) ExecuteAll

func (s *Service) ExecuteAll(ctx context.Context, query string) (*Result, error)

ExecuteAll runs a SOQL query including deleted/archived records.

func (*Service) ExecuteAllRecords

func (s *Service) ExecuteAllRecords(ctx context.Context, query string) ([]*SObject, error)

ExecuteAll fetches all records across pagination.

func (*Service) ExecuteWithCallback

func (s *Service) ExecuteWithCallback(ctx context.Context, query string, fn func(*SObject) error) error

ExecuteWithCallback executes a query and calls fn for each record.

func (*Service) NewBuilder

func (s *Service) NewBuilder(objectType string) *Builder

NewBuilder creates a new SOQL query builder.

func (*Service) QueryMore

func (s *Service) QueryMore(ctx context.Context, nextRecordsURL string) (*Result, error)

QueryMore retrieves the next batch of query results.

Jump to

Keyboard shortcuts

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