View Source ArangoXEcto.Association.Graph (ArangoX Ecto v2.0.0)

The association struct for a graph association.

This is based off of the many_to_many relationship but modified to suit graph relations. This is uses graph traversal queries instead of the standard SQL format queries.

This allows for multiple related schemas through the same edge. E.g.

graph :friends, [Person, Pet], edge: Friends, on_replace: :delete

Use the fields on the schema to identify which schema to use. If any of the fields in the list exists then it will use the key as the module.

graph :friends, %{
    Person => [:first_name],
    Pet => [:name]
  },
  edge: Friends

The available fields are:

  • cardinality - The association cardinality, always :many
  • field - The name of the association field on the schema
  • owner - The schema where the association was defined
  • owner_key - The key on the owner schema used for the association
  • related - The schema that is associated
  • related_key - The key on the related schema used for the association
  • queryables - The real query to use for querying association
  • defaults - default fields used when building the association
  • relationship - The relationship to the specified schema, default :parent
  • on_replace - The action taken on associations when schema is replaced

Summary

Types

t()

(since 2.0.0)
@type t() :: %ArangoXEcto.Association.Graph{
  cardinality: :many,
  direction: :outbound | :inbound,
  edge: module(),
  field: atom(),
  mapping: map(),
  on_cast: nil | (... -> any()),
  on_delete: nil | (... -> any()),
  on_replace: atom(),
  ordered: false,
  owner: atom(),
  owner_key: atom(),
  preload_order: list(),
  queryables: [atom()],
  related: [atom()],
  relationship: :child,
  unique: false,
  where: Keyword.t()
}

Functions

assoc_query(refl, values)

(since 2.0.0)