query

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clause

type Clause struct {
	Field    Field    // The field to filter on.
	Operator Operator // The comparison operator.
	Value    any      // The value to compare against.
}

Clause represents a single filtering condition in a query. It specifies the field to filter on, the operator to use, and the value to compare.

func ClauseWithCreatedAt

func ClauseWithCreatedAt(createdAt int64) Clause

ClauseWithCreatedAt creates a Clause that filters by the created_at field using the equality operator and the provided timestamp value.

func ClauseWithCreatedBefore

func ClauseWithCreatedBefore(createdAt int64) Clause

ClauseWithCreatedBefore creates a Clause that filters for entities with a created_at field less than or equal to the provided timestamp.

func ClauseWithID

func ClauseWithID(id uuid.UUID) Clause

ClauseWithID creates a Clause that filters by the entity's ID field using the equality operator and the provided UUID value.

func ClauseWithIsNotified

func ClauseWithIsNotified(isNotified bool) Clause

ClauseWithIsNotified creates a Clause that filters results based on the isNotified field. It returns a Clause that matches entities where the isNotified field equals the specified value.

func ClauseWithJobID

func ClauseWithJobID(jobID uuid.UUID) Clause

ClauseWithJobID creates a Clause that filters by the job ID field using the equality operator and the provided UUID value.

func ClauseWithReadyToBeSent

func ClauseWithReadyToBeSent(val int64) Clause

ClauseWithReadyToBeSent creates a Clause that filters for entities where the sum of reconcile_after_sec and last_reconciled_at is less than or equal to the current time.

func ClauseWithStatus

func ClauseWithStatus(status string) Clause

ClauseWithStatus creates a Clause that filters by the status field using the equality operator and the provided status value.

func ClauseWithStatuses

func ClauseWithStatuses(statuses ...string) Clause

ClauseWithStatuses creates a Clause that filters by the status field using the in operator and the provided status values.

func ClauseWithUpdatedBefore

func ClauseWithUpdatedBefore(updatedAt int64) Clause

ClauseWithUpdatedBefore creates a Clause that filters for entities with a created_at field less than or equal to the provided timestamp.

type Cursor

type Cursor struct {
	Timestamp int64     // Timestamp for the cursor position.
	ID        uuid.UUID // Unique identifier for the cursor position.
}

Cursor represents a pagination cursor for queries. It consists of a timestamp and a unique identifier to support efficient and consistent pagination of results.

type EntityName

type EntityName string

EntityName represents the name of the entity in the query.

const (
	EntityNameJobs      EntityName = "jobs"
	EntityNameTasks     EntityName = "tasks"
	EntityNameJobCursor EntityName = "job_cursor"
	EntityNameJobEvent  EntityName = "job_event"
)

type Field

type Field string

Field represents the field name in the query.

type Operator

type Operator string

Operator represents the operator used in the query.

type OrderBy

type OrderBy struct {
	Field       Field // The field to order by.
	IsAscending bool  // If true, orders in ascending order; otherwise, descending.
}

OrderBy represents the ordering of query results.

func OrderByUpdatedAtAscending

func OrderByUpdatedAtAscending() OrderBy

OrderByUpdatedAtAscending creates an OrderBy clause that orders results by the updated_at field in ascending order.

type Query

type Query struct {
	EntityName    EntityName // Name of the entity being queried.
	Clauses       []Clause   // Filtering clauses for the query.
	Cursor        Cursor     // Cursor for pagination.
	Limit         int        // Maximum number of results to return.
	RetrievalMode RetrievalMode
	OrderBy       []OrderBy // Fields to order the results by.
}

Query represents a database query for a specific entity type. It includes filtering clauses, pagination cursor, result limit, and an option to enable queue-like retrieval mode.

type RetrievalMode added in v0.2.0

type RetrievalMode int
const (
	RetrievalModeDefault RetrievalMode = iota
	RetrievalModeForUpdate
	RetrievalModeForUpdateSkipLocked
)

Jump to

Keyboard shortcuts

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