Closed kopylovvlad closed 6 years ago
We're actually in the process of phasing out finder methods for ActiveRel
. Neo4j encourages finding things by nodes first and then traversing relationships. There is no performant way (at least in Cypher) to find a relationship by an ID. So instead of saying:
VotedFor.where(from_class: user)
user.quizzes.each_rel
# Or to just get one:
user.quizzes.each_rel.first
Does that make sense? That should probably be clearer in the docs
FYI there's no need to include Neo4j::Timestamps::Created
or Neo4j::Timestamps::Updated
when you've included Neo4j::Timestamps
. Neo4j::Timestamps
will bring in both for you.
I like neo4jrb, it is cool thing. But ActiveRel has some strange behavior.
I have 3 classes (2 ActiveNode and 1 ActiveRel) like this:
Let's create instances
Alright, it works pretty well. Let's try to find an instance of VotedFor class.
Why .where does not support searching by from_class, from_class? It will be awesome feature.
Why .where does not work with id?
Methods .find and .find_by_id work perfectly, but...
Let's delete an instance of VotedFor
And after that, we will try to find our instance by .find and .find_by_id
Why does it raise an NoMethodError? Maybe, the better way will be raise something like Neo4j::ActiveNode::Labels::RecordNotFound?
For example: ActiveNode works perfectly and can raise RecordNotFound like rails/activerecord.
Runtime information:
Neo4j database version:
neo4j
gem version: 9.1.3neo4j-core
gem version: 8.1.0