This section is empty.


This section is empty.


func From

func From(name string, t interface{}) *inverseBuilder

From represents a reversed-edge between two vertices that has a back-reference to its source edge.

func To

func To(name string, t interface{}) *assocBuilder

To defines an association edge between two vertices.


type Annotation

type Annotation struct {
	// The StructTag option allows overriding the struct-tag
	// of the `Edges` field in the generated entity. For example:
	//	edge.Annotation{
	//		StructTag: `json: "pet_edges"`
	//	}
	StructTag string

Annotation is a builtin schema annotation for configuring the edges behavior in codegen.

func (Annotation) Merge

func (a Annotation) Merge(other schema.Annotation) schema.Annotation

Merge implements the schema.Merger interface.

func (Annotation) Name

func (Annotation) Name() string

Name describes the annotation name.

type Descriptor

type Descriptor struct {
	Tag         string              // struct tag.
	Type        string              // edge type.
	Name        string              // edge name.
	RefName     string              // ref name; inverse only.
	Ref         *Descriptor         // edge reference; to/from of the same type.
	Unique      bool                // unique edge.
	Inverse     bool                // inverse edge.
	Required    bool                // required on creation.
	StorageKey  *StorageKey         // optional storage-key configuration.
	Annotations []schema.Annotation // edge annotations.

A Descriptor for edge configuration.

type StorageKey

type StorageKey struct {
	Table   string   // Table or label.
	Columns []string // Foreign-key columns.

StorageKey holds the configuration for edge storage-key.

type StorageOption

type StorageOption func(*StorageKey)

StorageOption allows for setting the storage configuration using functional options.

func Column

func Column(name string) StorageOption

Column sets the foreign-key column name option for O2O, O2M and M2O edges. Note that, for M2M edges (2 columns), use the edge.Columns option.

func Columns

func Columns(to, from string) StorageOption

Columns sets the foreign-key column names option for M2M edges. The 1st column defines the name of the "To" edge, and the 2nd defines the name of the "From" edge (inverse edge). Note that, for O2O, O2M and M2O edges, use the edge.Column option.

func Table

func Table(name string) StorageOption

Table sets the table name option for M2M edges.