我有一个应用程序使用Neo4j后端一个模型和PostgreSQL后端所有其他模型。这里是Neo4j模型:关联Neo4j :: ActiveNode模型与ActiveRecord模型
class Concept
include Neo4j::ActiveNode
property :name
def references
Reference.where(concept_uuid: uuid)
end
end
这里是一个ActiveRecord模型。引用表上有一个content_uuid:
class Reference < ActiveRecord::Base
def concept
Concept.where(uuid: concept_uuid).first
end
end
这工作,我可以这样做Reference.first.concept
和Concept.first.references
事情没有发生任何事件。我想,虽然,我可以做一些简单的像这个:
class Reference < ActiveRecord::Base
belongs_to :concepts
end
class Concept < ActiveRecord::Base
include Neo4j::ActiveNode
property :name
has_many :references
end
因为当时我得到的东西像Concept.first.references << new_reference
开箱。有没有这样的功能?