function

Relationship

func Relationship( name string, options ...RelationshipOption, ) Definition

Define a singular, many, or polymorphic document reference.

Source field/options.go:640

@param name
The name value.
@param options
The options value.
@returns
The declared result.

Use To for one target, ToAny for polymorphism, and HasMany or ToMany for a list.

Example

go
field.Relationship(
  "authors",
  field.To("users"),
  field.HasMany(),
  field.OnDelete(field.ReferenceDeleteRestrict),
)

Related types

Related guides