index

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package index holds the index builders used in an entity schema.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

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

Column is a single indexed column together with its sort direction.

func (Column) GetName

func (c Column) GetName() string

GetName returns the column name.

func (Column) IsDesc

func (c Column) IsDesc() bool

IsDesc reports if the column is sorted descending.

type Index

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

Index holds the state of one index.

func (Index) Asc

func (i Index) Asc(field string) IndexOperations

Asc appends a column sorted ascending.

func (Index) Desc

func (i Index) Desc(field string) IndexOperations

Desc appends a column sorted descending.

func (Index) GetColumns

func (i Index) GetColumns() []Column

GetColumns returns the columns with their sort direction, in order.

func (Index) GetFields

func (i Index) GetFields() []string

GetFields returns just the column names, in order.

func (Index) GetName

func (i Index) GetName() string

GetName returns the custom index name, or "" when auto-generated.

func (Index) GetType

func (i Index) GetType() Type

GetType returns the index kind, primary or index.

func (Index) Index

func (Index) Index()

marker method for sealed interface

func (Index) IsUnique

func (i Index) IsUnique() bool

IsUnique reports if the index is a unique constraint.

func (Index) Name

func (i Index) Name(name string) IndexOperations

Name overrides the auto-generated index name.

func (Index) Unique

func (i Index) Unique() IndexOperations

Unique turns the index into a unique constraint.

type IndexBuilder

type IndexBuilder interface {
	Index()
}

IndexBuilder is implemented by every index.

func Primary

func Primary(fields ...string) IndexBuilder

Primary declares the primary key over the given fields.

type IndexOperations

type IndexOperations interface {
	IndexBuilder
	// Unique turns the index into a unique constraint.
	Unique() IndexOperations
	// Name overrides the auto-generated index name
	Name(name string) IndexOperations
	// Asc appends a column sorted ascending.
	Asc(field string) IndexOperations
	// Desc appends a column sorted descending.
	Desc(field string) IndexOperations
}

IndexOperations exposes the fluent modifiers available on a Fields() index.

func Fields

func Fields(fields ...string) IndexOperations

Fields declares a secondary index over the given fields.

type Type

type Type string

Type tells which kind of index is described.

const (
	// TypePrimary marks a (compound) primary key.
	TypePrimary Type = "primary"
	// TypeIndex is a regular secondary index (optionally unique).
	TypeIndex Type = "index"
)

Jump to

Keyboard shortcuts

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