# `AshVersioned.VersionedRelationship`

Shared configuration for relationships to versioned resources, used by
`belongs_to_actor` (`AshVersioned.Resource`) and by `belongs_to_versioned`,
`has_one_versioned`, and `has_many_versioned` (`AshVersioned.Relationships`).

A relationship to a versioned resource:

- reads through the destination's `__ash_versioned_read__` action, bypassing archive
  filtering;
- filters on the destination's `__ash_versioned_latest__` calculation, so that loads,
  aggregates, `exists`, and data layer joins all see only the latest version; and
- for `belongs_to`, joins on the destination's identity attribute rather than its
  primary key, so it never creates a foreign key (the identity is not unique across
  versions).

# `belongs_to_options`

Options for `Spark.Dsl.Transformer.build_entity!/4` building a `belongs_to` to
a versioned resource with the given identity attribute.

# `ignore_reference`

Adds an ignored `postgres.references` entry for the relationship, so that AshPostgres
doesn't generate a foreign key to a non-unique identity attribute. Does nothing if the
data layer isn't AshPostgres or if a reference for the relationship is already declared.

# `latest_calculation`

The name of the boolean calculation added to every `AshVersioned.Resource` to filter to
the latest version of a record.

# `latest_filter`

The filter applied to every relationship to a versioned resource.

# `mark`

Marks a relationship as a versioned relationship, already configured for a versioned
destination.

# `put_versioned`

Applies the latest filter to a relationship struct before its Ash `transform/1` runs,
and marks it as a versioned relationship.

# `read_action`

The name of the read action added to every `AshVersioned.Resource`, scoped to the
latest version of each record, ignoring archiving.

# `versioned?`

Returns `true` if the relationship was declared with one of the `*_versioned`
relationship entities, or is a `belongs_to_actor` relationship to a versioned resource.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
