我在我的 rails 应用程序中使用 Neo4j.rb。我在多态性方面遇到了麻烦。
我有这样的东西我有一个看起来像这样的用户类:
class User
include Neo4j::ActiveNode
#other properties
has_many: out, :social_media_content, model_class: :SocialMediaContent
end
我有 SocialMediaContent 类
class SocialMediaContent
include Neo4j::ActiveNode # Is it necessary?
property :first_name, type: Integer
property :first_name, type: Integer
end
我想要一个继承自社交媒体内容的图像类和视频类
这是否意味着在创建 SocialMediaContent 和用户之间的关系时,我可以提供图像或视频对象而不是 SocialMediaContent,它是如何在数据库中发生的,我是否也需要为图像创建一个节点,或者它可以是一个普通的物体。
IE
class Image < SocialMediaContent
include Neo4j::ActiveNode #Do i have to do this?
我想要这样的行为:每个用户都有许多 SocialMediaContent 可以是图像或视频(现在)我现在不想指定,其中一个是图像,哪个是视频。
谁能建议我如何实现这一目标?最后我可以存储一个 SocialMediaContent 数组而不是 has_many 关联(哪个更好?)