Documentation ¶
Index ¶
Constants ¶
const ( // DefaultPageSize defines the default number of results to select per page. DefaultPageSize = 30 SortOrderAsc = "asc" SortOrderDesc = "desc" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attribute ¶
type Attribute struct { Name string // contains filtered or unexported fields }
Attribute defines a transaction event attribute.
func NewAttribute ¶
NewAttribute creates a new transaction event attribute.
type Cursor ¶
type Cursor interface { // Err returns the last error seen by the Cursor, or nil if no error has occurred. Err() error // Next prepares the next result to be read with the Scan method. // It returns true on success, or false if there is no next result row or an error // happened while preparing it. Err should be consulted to distinguish between the // two cases. // // Every call to Scan, even the first one, must be preceded by a call to Next. Next() bool // Scan copies the query row into the pointed values. Scan(values ...any) error // Close closes the cursor preventing further iterations. // If Next is called and returns false and there are no further result sets, // the cursor is closed automatically and it will suffice to check the result of Err. // This method is idempotent meaning that after the first call, any subsequent calls // will not change the state. Close() error }
Cursor defines a cursor to iterate query results.
type Event ¶
type Event struct { ID int64 TXHash string Index uint64 Type string Attributes []Attribute CreatedAt time.Time }
Event defines a transaction event.
type EventQuery ¶
EventQuery describes how to select event values from a data backend.
func NewEventQuery ¶
func NewEventQuery(options ...Option) EventQuery
NewEventQuery creates a new query that selects events.
type Filter ¶
type Filter interface { fmt.Stringer // Field returns the name of the filtered field. Field() string // Value returns the value to use for filtering. Value() any }
Filter describes a filter to apply to a query.
type Filterer ¶
type Filterer interface { // Filters returns the list of filters to apply to the query. Filters() []Filter }
Filterer describes support for filtering query results.
type Option ¶
type Option func(*Query)
Option configures queries.
func AtPage ¶
AtPage assigns a page to select. Pages start from page one, so assigning page zero selects the first page.
func SortByFields ¶
SortByFields orders the query by one or more fields. Use `WithSortBy` option when multiple order by directions are needed.
func WithFilters ¶
WithFilters adds one or more filters to apply to the query.
func WithPageSize ¶
WithPageSize assigns the number of results to select per page. The default page size is used when size zero is assigned.
func WithSortBy ¶
WithSortBy orders the query by one or more fields.
func WithoutPaging ¶
func WithoutPaging() Option
WithoutPaging disables the paging of results. All results are selected when paging is disabled.
type Pager ¶
type Pager interface { // PageSize returns the size for each query result set. PageSize() uint32 // AtPage returns the result set page to query. AtPage() uint32 // IsPagingEnabled checks if the query results should be paginated. IsPagingEnabled() bool }
Pager describes support for paging query results.
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query describes how to select values from a data backend.
func New ¶
New creates a new query that selects results from an entity. The name is the name of an entity which depending on the data backend have different meanings. In a relational database the name should be a table, function or view, while in a NoSQL database it should be a collection.
func (Query) Args ¶
Args returns the arguments for query. Arguments are used when the query calls a function in the data backend.
func (Query) IsPagingEnabled ¶
IsPagingEnabled checks if the query results should be paginated.
func (Query) Name ¶
Name returns the name of the database table, collection, view or function to select.