options

package
v1.57.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 7 Imported by: 6

Documentation

Overview

Code generated by github.com/ecordell/optgen. DO NOT EDIT.

Code generated by github.com/ecordell/optgen. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var (

	// LimitOne is a constant *uint64 that can be used with WithLimit requests.
	LimitOne = &one
)

Functions

func ToRelationship added in v1.39.0

func ToRelationship(c Cursor) *tuple.Relationship

Types

type Cursor

type Cursor *tuple.Relationship

func ToCursor added in v1.39.0

func ToCursor(r tuple.Relationship) Cursor

type DeleteOptions added in v1.30.0

type DeleteOptions struct {
	DeleteLimit *uint64 `debugmap:"visible"`

	// CursoredDelete requests cursored batch deletion: the delete is performed
	// in a defined order and DeleteRelationshipsResult.Cursor reports the last
	// relationship deleted, so a subsequent call can resume after it. Requires
	// DeleteLimit. Supported only by datastores implementing
	// datastore.CursoredDeleteDatastore.
	CursoredDelete bool `debugmap:"visible"`

	// DeleteAfter restricts the delete to relationships sorted strictly after
	// the cursor in the datastore's delete order. Implies CursoredDelete.
	DeleteAfter Cursor `debugmap:"visible"`
}

DeleteOptions are the options that can affect the results of a delete relationships operation.

func DeleteOptionsWithOptions added in v1.30.0

func DeleteOptionsWithOptions(d *DeleteOptions, opts ...DeleteOptionsOption) *DeleteOptions

DeleteOptionsWithOptions configures an existing DeleteOptions with the passed in options set

func NewDeleteOptionsWithOptions added in v1.30.0

func NewDeleteOptionsWithOptions(opts ...DeleteOptionsOption) *DeleteOptions

NewDeleteOptionsWithOptions creates a new DeleteOptions with the passed in options set

func NewDeleteOptionsWithOptionsAndDefaults added in v1.30.0

func NewDeleteOptionsWithOptionsAndDefaults(opts ...DeleteOptionsOption) *DeleteOptions

NewDeleteOptionsWithOptionsAndDefaults creates a new DeleteOptions with the passed in options set starting from the defaults

func (*DeleteOptions) DebugMap added in v1.30.0

func (d *DeleteOptions) DebugMap() map[string]any

DebugMap returns a map form of DeleteOptions for debugging

func (*DeleteOptions) FlatDebugMap added in v1.49.0

func (d *DeleteOptions) FlatDebugMap() map[string]any

FlatDebugMap returns a flattened map form of DeleteOptions for debugging Nested maps are flattened using dot notation (e.g., "parent.child.field")

func (*DeleteOptions) IsCursoredDelete added in v1.57.0

func (d *DeleteOptions) IsCursoredDelete() bool

IsCursoredDelete reports whether a cursored delete was requested, either explicitly or implicitly by supplying a cursor.

func (*DeleteOptions) ToOption added in v1.30.0

func (d *DeleteOptions) ToOption() DeleteOptionsOption

ToOption returns a new DeleteOptionsOption that sets the values from the passed in DeleteOptions

func (*DeleteOptions) ValidateCursoredDelete added in v1.57.0

func (d *DeleteOptions) ValidateCursoredDelete() error

ValidateCursoredDelete checks a cursored delete request for internal consistency. It returns an error if a cursored delete was requested without a positive limit. It does not check whether the datastore supports one.

func (*DeleteOptions) WithOptions added in v1.30.0

func (d *DeleteOptions) WithOptions(opts ...DeleteOptionsOption) *DeleteOptions

WithOptions configures the receiver DeleteOptions with the passed in options set

type DeleteOptionsOption added in v1.30.0

type DeleteOptionsOption func(d *DeleteOptions)

func WithCursoredDelete added in v1.57.0

func WithCursoredDelete(cursoredDelete bool) DeleteOptionsOption

WithCursoredDelete returns an option that can set CursoredDelete on a DeleteOptions

func WithDeleteAfter added in v1.57.0

func WithDeleteAfter(deleteAfter Cursor) DeleteOptionsOption

WithDeleteAfter returns an option that can set DeleteAfter on a DeleteOptions

func WithDeleteLimit added in v1.30.0

func WithDeleteLimit(deleteLimit *uint64) DeleteOptionsOption

WithDeleteLimit returns an option that can set DeleteLimit on a DeleteOptions

type QueryOptions

type QueryOptions struct {
	Limit          *uint64   `debugmap:"visible"`
	Sort           SortOrder `debugmap:"visible"`
	After          Cursor    `debugmap:"visible"`
	BeforeOrEqual  Cursor    `debugmap:"visible"`
	SkipCaveats    bool      `debugmap:"visible"`
	SkipExpiration bool      `debugmap:"visible"`

	// SQLCheckAssertionForTest is a function that can be used to assert a condition on the SQL query string.
	// For testing and validation only.
	SQLCheckAssertionForTest SQLCheckAssertionForTest `debugmap:"visible"`

	// SQLExplainCallbackForTest is a callback invoked with the explain plan of the SQL query string.
	// For testing and validation only.
	SQLExplainCallbackForTest SQLExplainCallbackForTest `debugmap:"visible"`

	// QueryShape is the marked shape of the query.
	// For testing and validation only.
	QueryShape queryshape.Shape `debugmap:"visible"`

	// UseTupleComparison, when true, overrides the schema's PaginationFilterType
	// to use tuple comparison syntax (e.g., (a,b,c) > (1,2,3)) instead of
	// the expanded OR/AND logic. This avoids CRDB's union-all + distinct plan
	// that causes temp storage exhaustion on large range-bounded queries.
	UseTupleComparison bool `debugmap:"visible"`
}

QueryOptions are the options that can affect the results of a normal forward query.

func NewQueryOptionsWithOptions

func NewQueryOptionsWithOptions(opts ...QueryOptionsOption) *QueryOptions

NewQueryOptionsWithOptions creates a new QueryOptions with the passed in options set

func NewQueryOptionsWithOptionsAndDefaults added in v1.22.0

func NewQueryOptionsWithOptionsAndDefaults(opts ...QueryOptionsOption) *QueryOptions

NewQueryOptionsWithOptionsAndDefaults creates a new QueryOptions with the passed in options set starting from the defaults

func QueryOptionsWithOptions

func QueryOptionsWithOptions(q *QueryOptions, opts ...QueryOptionsOption) *QueryOptions

QueryOptionsWithOptions configures an existing QueryOptions with the passed in options set

func (*QueryOptions) DebugMap added in v1.22.0

func (q *QueryOptions) DebugMap() map[string]any

DebugMap returns a map form of QueryOptions for debugging

func (*QueryOptions) FlatDebugMap added in v1.49.0

func (q *QueryOptions) FlatDebugMap() map[string]any

FlatDebugMap returns a flattened map form of QueryOptions for debugging Nested maps are flattened using dot notation (e.g., "parent.child.field")

func (*QueryOptions) ReturnsAllUnordered added in v1.57.0

func (opts *QueryOptions) ReturnsAllUnordered() bool

ReturnsAllUnordered reports whether a query with these options returns every matching relationship, in no specified order. It is false if the options set a limit, a sort order, a cursor, a SQL test hook or tuple comparison. SkipCaveats and SkipExpiration only clear columns of each relationship, and QueryShape only labels the query.

func (*QueryOptions) ToOption

func (q *QueryOptions) ToOption() QueryOptionsOption

ToOption returns a new QueryOptionsOption that sets the values from the passed in QueryOptions

func (*QueryOptions) WithOptions added in v1.22.0

func (q *QueryOptions) WithOptions(opts ...QueryOptionsOption) *QueryOptions

WithOptions configures the receiver QueryOptions with the passed in options set

type QueryOptionsOption

type QueryOptionsOption func(q *QueryOptions)

func WithAfter

func WithAfter(after Cursor) QueryOptionsOption

WithAfter returns an option that can set After on a QueryOptions

func WithBeforeOrEqual added in v1.52.0

func WithBeforeOrEqual(beforeOrEqual Cursor) QueryOptionsOption

WithBeforeOrEqual returns an option that can set BeforeOrEqual on a QueryOptions

func WithLimit

func WithLimit(limit *uint64) QueryOptionsOption

WithLimit returns an option that can set Limit on a QueryOptions

func WithQueryShape added in v1.42.0

func WithQueryShape(queryShape queryshape.Shape) QueryOptionsOption

WithQueryShape returns an option that can set QueryShape on a QueryOptions

func WithSQLCheckAssertionForTest added in v1.42.0

func WithSQLCheckAssertionForTest(sQLCheckAssertionForTest SQLCheckAssertionForTest) QueryOptionsOption

WithSQLCheckAssertionForTest returns an option that can set SQLCheckAssertionForTest on a QueryOptions

func WithSQLExplainCallbackForTest added in v1.42.0

func WithSQLExplainCallbackForTest(sQLExplainCallbackForTest SQLExplainCallbackForTest) QueryOptionsOption

WithSQLExplainCallbackForTest returns an option that can set SQLExplainCallbackForTest on a QueryOptions

func WithSkipCaveats added in v1.40.0

func WithSkipCaveats(skipCaveats bool) QueryOptionsOption

WithSkipCaveats returns an option that can set SkipCaveats on a QueryOptions

func WithSkipExpiration added in v1.40.0

func WithSkipExpiration(skipExpiration bool) QueryOptionsOption

WithSkipExpiration returns an option that can set SkipExpiration on a QueryOptions

func WithSort

func WithSort(sort SortOrder) QueryOptionsOption

WithSort returns an option that can set Sort on a QueryOptions

func WithUseTupleComparison added in v1.52.0

func WithUseTupleComparison(useTupleComparison bool) QueryOptionsOption

WithUseTupleComparison returns an option that can set UseTupleComparison on a QueryOptions

type RWTOptions added in v1.22.0

type RWTOptions struct {
	DisableRetries bool             `debugmap:"visible"`
	Metadata       *structpb.Struct `debugmap:"visible"`
	// SchemaHashPrecondition, when non-empty, causes ReadWriteTx to verify the
	// stored schema hash equals this value before invoking the user callback.
	// Returns ErrSchemaHashPreconditionFailed if the hash differs.
	SchemaHashPrecondition string `debugmap:"visible"`
	// SchemaHashPreconditionExclusive, when true, causes the schema hash precondition
	// check to acquire an exclusive (FOR UPDATE) lock rather than a shared (FOR SHARE)
	// lock. Set by schema write transactions; relationship writes use the default shared lock
	// so they can proceed concurrently.
	SchemaHashPreconditionExclusive bool `debugmap:"visible"`
	// SkipCommitRevision, when true, allows a datastore to skip determining the
	// transaction's commit revision, returning datastore.NoRevision instead. It
	// is an optimization for callers that discard the revision, such as bulk
	// deletion: on CockroachDB the commit revision is read with a separate SHOW
	// COMMIT TIMESTAMP round trip per transaction, which dominates the cost of an
	// otherwise trivial batch. Datastores that derive the revision as a byproduct
	// of the transaction may ignore this option.
	SkipCommitRevision bool `debugmap:"visible"`
}

RWTOptions are options that can affect the way a read-write transaction is executed.

func NewRWTOptionsWithOptions added in v1.22.0

func NewRWTOptionsWithOptions(opts ...RWTOptionsOption) *RWTOptions

NewRWTOptionsWithOptions creates a new RWTOptions with the passed in options set

func NewRWTOptionsWithOptionsAndDefaults added in v1.22.0

func NewRWTOptionsWithOptionsAndDefaults(opts ...RWTOptionsOption) *RWTOptions

NewRWTOptionsWithOptionsAndDefaults creates a new RWTOptions with the passed in options set starting from the defaults

func RWTOptionsWithOptions added in v1.22.0

func RWTOptionsWithOptions(r *RWTOptions, opts ...RWTOptionsOption) *RWTOptions

RWTOptionsWithOptions configures an existing RWTOptions with the passed in options set

func (*RWTOptions) DebugMap added in v1.22.0

func (r *RWTOptions) DebugMap() map[string]any

DebugMap returns a map form of RWTOptions for debugging

func (*RWTOptions) FlatDebugMap added in v1.49.0

func (r *RWTOptions) FlatDebugMap() map[string]any

FlatDebugMap returns a flattened map form of RWTOptions for debugging Nested maps are flattened using dot notation (e.g., "parent.child.field")

func (*RWTOptions) ToOption added in v1.22.0

func (r *RWTOptions) ToOption() RWTOptionsOption

ToOption returns a new RWTOptionsOption that sets the values from the passed in RWTOptions

func (*RWTOptions) WithOptions added in v1.22.0

func (r *RWTOptions) WithOptions(opts ...RWTOptionsOption) *RWTOptions

WithOptions configures the receiver RWTOptions with the passed in options set

type RWTOptionsOption added in v1.22.0

type RWTOptionsOption func(r *RWTOptions)

func WithDisableRetries added in v1.22.0

func WithDisableRetries(disableRetries bool) RWTOptionsOption

WithDisableRetries returns an option that can set DisableRetries on a RWTOptions

func WithMetadata added in v1.38.0

func WithMetadata(metadata *structpb.Struct) RWTOptionsOption

WithMetadata returns an option that can set Metadata on a RWTOptions

func WithSchemaHashPrecondition added in v1.54.0

func WithSchemaHashPrecondition(schemaHashPrecondition string) RWTOptionsOption

WithSchemaHashPrecondition returns an option that can set SchemaHashPrecondition on a RWTOptions

func WithSchemaHashPreconditionExclusive added in v1.54.0

func WithSchemaHashPreconditionExclusive(schemaHashPreconditionExclusive bool) RWTOptionsOption

WithSchemaHashPreconditionExclusive returns an option that can set SchemaHashPreconditionExclusive on a RWTOptions

func WithSkipCommitRevision added in v1.57.0

func WithSkipCommitRevision(skipCommitRevision bool) RWTOptionsOption

WithSkipCommitRevision returns an option that can set SkipCommitRevision on a RWTOptions

type ResourceRelation

type ResourceRelation struct {
	Namespace string
	Relation  string
}

ResourceRelation combines a resource object type and relation.

type ReverseQueryOptions

type ReverseQueryOptions struct {
	ResRelation *ResourceRelation `debugmap:"visible"`

	LimitForReverse          *uint64   `debugmap:"visible"`
	SortForReverse           SortOrder `debugmap:"visible"`
	AfterForReverse          Cursor    `debugmap:"visible"`
	SkipCaveatsForReverse    bool      `debugmap:"visible"`
	SkipExpirationForReverse bool      `debugmap:"visible"`

	// SQLExplainCallbackForTestForReverse is a callback invoked with the explain plan of the SQL query string.
	// For testing and validation only.
	SQLExplainCallbackForTestForReverse SQLExplainCallbackForTest `debugmap:"visible"`

	// QueryShapeForReverse is the marked shape of the reverse query.
	// For testing and validation only.
	QueryShapeForReverse queryshape.Shape `debugmap:"visible"`
}

ReverseQueryOptions are the options that can affect the results of a reverse query.

func NewReverseQueryOptionsWithOptions

func NewReverseQueryOptionsWithOptions(opts ...ReverseQueryOptionsOption) *ReverseQueryOptions

NewReverseQueryOptionsWithOptions creates a new ReverseQueryOptions with the passed in options set

func NewReverseQueryOptionsWithOptionsAndDefaults added in v1.22.0

func NewReverseQueryOptionsWithOptionsAndDefaults(opts ...ReverseQueryOptionsOption) *ReverseQueryOptions

NewReverseQueryOptionsWithOptionsAndDefaults creates a new ReverseQueryOptions with the passed in options set starting from the defaults

func ReverseQueryOptionsWithOptions

func ReverseQueryOptionsWithOptions(r *ReverseQueryOptions, opts ...ReverseQueryOptionsOption) *ReverseQueryOptions

ReverseQueryOptionsWithOptions configures an existing ReverseQueryOptions with the passed in options set

func (*ReverseQueryOptions) DebugMap added in v1.22.0

func (r *ReverseQueryOptions) DebugMap() map[string]any

DebugMap returns a map form of ReverseQueryOptions for debugging

func (*ReverseQueryOptions) FlatDebugMap added in v1.49.0

func (r *ReverseQueryOptions) FlatDebugMap() map[string]any

FlatDebugMap returns a flattened map form of ReverseQueryOptions for debugging Nested maps are flattened using dot notation (e.g., "parent.child.field")

func (*ReverseQueryOptions) ToOption

ToOption returns a new ReverseQueryOptionsOption that sets the values from the passed in ReverseQueryOptions

func (*ReverseQueryOptions) WithOptions added in v1.22.0

WithOptions configures the receiver ReverseQueryOptions with the passed in options set

type ReverseQueryOptionsOption

type ReverseQueryOptionsOption func(r *ReverseQueryOptions)

func WithAfterForReverse

func WithAfterForReverse(afterForReverse Cursor) ReverseQueryOptionsOption

WithAfterForReverse returns an option that can set AfterForReverse on a ReverseQueryOptions

func WithLimitForReverse

func WithLimitForReverse(limitForReverse *uint64) ReverseQueryOptionsOption

WithLimitForReverse returns an option that can set LimitForReverse on a ReverseQueryOptions

func WithQueryShapeForReverse added in v1.42.0

func WithQueryShapeForReverse(queryShapeForReverse queryshape.Shape) ReverseQueryOptionsOption

WithQueryShapeForReverse returns an option that can set QueryShapeForReverse on a ReverseQueryOptions

func WithResRelation

func WithResRelation(resRelation *ResourceRelation) ReverseQueryOptionsOption

WithResRelation returns an option that can set ResRelation on a ReverseQueryOptions

func WithSQLExplainCallbackForTestForReverse added in v1.42.0

func WithSQLExplainCallbackForTestForReverse(sQLExplainCallbackForTestForReverse SQLExplainCallbackForTest) ReverseQueryOptionsOption

WithSQLExplainCallbackForTestForReverse returns an option that can set SQLExplainCallbackForTestForReverse on a ReverseQueryOptions

func WithSkipCaveatsForReverse added in v1.44.4

func WithSkipCaveatsForReverse(skipCaveatsForReverse bool) ReverseQueryOptionsOption

WithSkipCaveatsForReverse returns an option that can set SkipCaveatsForReverse on a ReverseQueryOptions

func WithSkipExpirationForReverse added in v1.44.4

func WithSkipExpirationForReverse(skipExpirationForReverse bool) ReverseQueryOptionsOption

WithSkipExpirationForReverse returns an option that can set SkipExpirationForReverse on a ReverseQueryOptions

func WithSortForReverse

func WithSortForReverse(sortForReverse SortOrder) ReverseQueryOptionsOption

WithSortForReverse returns an option that can set SortForReverse on a ReverseQueryOptions

type SQLCheckAssertionForTest added in v1.42.0

type SQLCheckAssertionForTest func(sql string)

SQLCheckAssertionForTest is a function that can be used to assert a condition on the SQL query string. Assertions will only be run during testing and only apply in datastores that support SQL.

type SQLExplainCallbackForTest added in v1.42.0

type SQLExplainCallbackForTest func(ctx context.Context, sql string, args []any, shape queryshape.Shape, explain string, expectedIndexes SQLIndexInformation) error

SQLExplainCallbackForTest is a callback invoked with the explain plan of the SQL query string.

type SQLIndexInformation added in v1.42.0

type SQLIndexInformation struct {
	// ExpectedIndexNames are the name(s) of the index(es) that are expected to be used by this
	// SQL query.
	ExpectedIndexNames []string

	// ShapeServingIndexNames are the names of all indexes that serve at least one query shape.
	// Any index used by a query that is *not* in this set (e.g. maintenance indexes such as
	// those used for garbage collection or watch, or the implicit primary key) is considered a
	// small-data optimizer artifact rather than a meaningful index choice, and is ignored when
	// validating that an expected index was used.
	ShapeServingIndexNames []string
}

SQLIndexInformation holds the expected index names for a SQL query.

type SortOrder

type SortOrder int8

SortOrder is an enum which represents the order in which the caller would like the data returned.

const (
	// Unsorted lets the underlying datastore choose the order, or no order at all
	Unsorted SortOrder = iota

	// ByResource sorts the relationships by the resource component first
	ByResource

	// BySubject sorts the relationships by the subject component first. Note that
	// BySubject might be quite a bit slower than ByResource, as relationships are
	// indexed by resource.
	BySubject

	// ChooseEfficient lets the datastore choose the most efficient order based on the query shape and available indexes.
	ChooseEfficient
)

Jump to

Keyboard shortcuts

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