def save_word_order(prev, {next_1, next_2}) do
save_word_order(prev, next_1)
save_word_order(prev, next_2)
end
def save_word_order({prev_1, prev_2}, {_next_1, _next_2} = next) do
save_word_order(prev_1, next)
save_word_order(prev_2, next)
end
def save_word_order(prev, next) do
Bolt.Sips.query!(
Bolt.Sips.conn(),
"""
MATCH (prev:Word {word: $prev})
MATCH (next:Word {word: $next})
MERGE (prev) -[:PREVIOUS_OF]-> (next)
MERGE (next) -[:NEXT_TO]-> (prev)
""",
%{prev: prev, next: next},
timeout: 25000
)
end