ArangoXEcto.Schema.one_incoming
one_incoming
, go back to ArangoXEcto.Schema module for more information.
Defines an incoming relationship of one object
Unlike incoming/3
, this does not create a graph relation and instead places the _id
in a field. If the value
passed to the name attribute is :user
then the foreign key created on this schema will be :user_id
and will
store the full _id
of that user. By storing the full _id
, you are still able to perform full AQL queries.
This MUST be accompanied by a one_outgoing/3
definition in the other target schema.
Behind the scenes this injects the __id__
field to store the _id
value and uses the built-in Ecto belongs_to/3
function.
Options passed to the opts
attribute are passed to the belongs_to/3
definition. Refrain from overriding the
:references
and :foreign_key
attributes unless you know what you are doing.
Example
defmodule MyProject.Post do
use ArangoXEcto.Schema
schema "posts" do
field :title, :string
one_incoming :user, MyProject.User
end
end