Suppose we have
- Node:
User
name
: String
- Rel:
Transaction
amount
: Float
representing a simplized Bitcoin-like transaction, where a User sends coins to other Users. A Transaction has a property amount
which shows how much coin you're sending to the to_node
from from_node
.
Then now I want to get all the transactions (either uni- or bi- directionally) between Alice and Bob. How can I do this?
# user.rb
has_many :out, :receivers, rel_class: :Transaction
has_many :in, :senders, rel_class: :Transaction
# Console
alice = User.find_by(name: "Alice")
bob = User.find_by(name: "Bob")
# I want to do something like this:
Transaction.between(from: alice, to: bob)
# or this:
alice.receivers.rel_where(to_node: bob)
I was surprised that the latter isn't acceptable. It includes bob
directly into CYPHER.
Using Neo4jrb v8.0.0