Neo4j - relationships not working after including type in ROR classes definition -
i getting , author work of arts belonging author no longer retrieved.
> = author.find_by(author_name: 'camus, albert') => #<author author_id: 615454, author_name: "camus, albert"> > w = a.wokas => <associationproxy @query_proxy=<queryproxy author#wokas#wokas cypher: "match author615452, author615452-[rel1:`authored`]->(result_wokas:`woka`) (id(author615452) = {id_author615452})">> > w.count => 0
i should 300+ records.
in db name of relationship authored , classes definition are:
class author include neo4j::activenode property :author_name, type: string property :author_id, type: integer has_many :out, :wokas, type: 'authored' end class woka include neo4j::activenode property :author_id, type: integer property :publisher_id, type: integer property :language_id, type: integer property :woka_id, type: string #integer property :woka_title, type: string has_one :in, :author, type: 'authored' has_one :in, :publisher, type: 'published' has_one :in, :language, type: 'used' has_many :out, :bisacs, type: 'included' has_many :out, :descriptions, type: 'has_language' end
any clue why relationships not longer working?
the associations return associationproxy
objects now. in past returned queryproxy
objects. both there allow make chained calls on further associations or other class-level methods. this:
# returns `associationproxy` can use of description objects a.wokas.descriptions
if want see objects association can call to_a
on result this:
w = a.wokas.to_a
or iterate since associationproxy
objects enumerable
:
a.wokas.each |woka| # woka object end
as side note, 1 of reasons associationproxy
there allow eager loading described here (again, documentation won't complete until final release of 5.0).
lastly performance reasons i'd suggest using symbols whenever can. associations, example, can this:
has_many :out, :wokas, type: :authored
Comments
Post a Comment