ent: github.com/facebookincubator/ent/schema/index Index | Files

package index

import "github.com/facebookincubator/ent/schema/index"

Index

Package Files

index.go

type Builder Uses

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

Builder for indexes on vertex columns and edges in the graph.

func Edges Uses

func Edges(edges ...string) *Builder

Edges creates an index on the given vertex edge fields. Note that indexes are implemented only for SQL dialects, and does not support gremlin.

func (T) Indexes() []ent.Index {

	// Unique index of field under 2 edges.
	index.Field("name").
		Edges("parent", "type").
		Unique(),

}

func Fields Uses

func Fields(fields ...string) *Builder

Fields creates an index on the given vertex fields. Note that indexes are implemented only for SQL dialects, and does not support gremlin.

func (T) Indexes() []ent.Index {

	// Unique index on 2 fields.
	index.Fields("first", "last").
		Unique(),

	// Unique index of field under specific edge.
	index.Fields("name").
		FromEdges("parent").
		Unique(),

}

func (*Builder) Descriptor Uses

func (b *Builder) Descriptor() *Descriptor

Descriptor implements the ent.Descriptor interface.

func (*Builder) Edges Uses

func (b *Builder) Edges(edges ...string) *Builder

FromEdges sets the fields index to be unique under the set of edges (sub-graph). For example:

func (T) Indexes() []ent.Index {

	// Unique "name" field under the "parent" edge.
	index.Fields("name").
		Edges("parent").
		Unique(),
}

func (*Builder) Fields Uses

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

Fields sets the fields of the index.

func (T) Indexes() []ent.Index {

	// Unique "name" and "age" fields under the "parent" edge.
	index.Edges("parent").
		Fields("name", "age").
		Unique(),

}

func (*Builder) StorageKey Uses

func (b *Builder) StorageKey(key string) *Builder

StorageKey sets the storage key of the index. In SQL dialects, it's the index name.

func (*Builder) Unique Uses

func (b *Builder) Unique() *Builder

Unique sets the index to be a unique index. Note that defining a uniqueness on optional fields won't prevent duplicates if one of the column contains NULL values.

type Descriptor Uses

type Descriptor struct {
    Unique     bool     // unique index.
    Edges      []string // edge columns.
    Fields     []string // field columns.
    StorageKey string   // custom index name.
}

A Descriptor for index configuration.

Package index is imported by 2 packages. Updated 2019-11-19. Refresh now. Tools for package owners.