EctoNeo4j v0.6.2 Ecto.Adapters.Neo4j.Behaviour.Relationship View Source
Manage relationship operations
Link to this section Summary
Functions
Create the necessary relationships for the given schema data.
Extract data from the has_many
and has_one
associations and convert them into relationships.
Remove / add relationship.
Update relationship data.
Link to this section Functions
process_relationships(result)
View Source
process_relationships({:ok, Ecto.Schema.t()}) :: Ecto.Schema.t()
process_relationships({:ok, Ecto.Schema.t()}) :: Ecto.Schema.t()
Create the necessary relationships for the given schema data.
Extract data from the has_many
and has_one
associations and convert them into relationships.
Note that only 1-depth assocations are treated.
update(atom, node1_data, node2_data, rel_name)
View Source
update(:replace | :update, Ecto.Schema.t(), atom() | Ecto.Schema.t(), atom()) ::
nil | Ecto.Schema.t()
update(:replace | :update, Ecto.Schema.t(), atom() | Ecto.Schema.t(), atom()) :: nil | Ecto.Schema.t()
Remove / add relationship.
For this to work, has_one
, has_many
, belongs_to
declaration must have the option on_replace: :delete
.
:update
will add a new relationship (without its data, they will be added later during the update process)
:replace
will remove the relationship
This function should not be called directly but through Ecto.Adapters.Neo4j.update/3
Example
user = MyRepo.get!(User, user_uuid)
post = MyRepo.get!(Post, post_uuid)
# This will set the relationship (User)-[:WROTE]->(Post)
update(:update, user, post, :wrote_post)
# This will remove the relationship (User)-[:WROTE]->(Post)
update(:delete, user, post, :wrote_post)
update_data(node_schema, rel_field, changes, data)
View Source
update_data(atom(), atom(), map(), Ecto.Schema.t()) :: Bolt.Sips.Response.t()
update_data(atom(), atom(), map(), Ecto.Schema.t()) :: Bolt.Sips.Response.t()
Update relationship data.
This function should not be called directly but through Ecto.Adapters.Neo4j.update/3