Tag: neo4j.rb

Neo4j gem – 采集多个节点/关系

这可能是不可能的,因为它现在,但我有这样的查询 events = Event.as(:e).where(“(( e.date_start – {current_time} )/{one_day_p}) < 1 ").users(:u, :rel).where("rel.reminded = {reminded_p}" ).params(reminded_p: false, one_day_p: one_day, current_time: time).pluck(:e,:u, :rel) 目标是获取start_date少于一天的events 。 假设我试图采取事件,用户和关系。 我需要对每个人采取不同的行动。 我需要为每个event获取所有users并为每个用户执行电子邮件操作。 在该操作中,电子邮件需要能够访问该event 。 接下来,我需要将rel.reminded属性更新为true 。 有没有办法同时采取所有这些能够组织和执行这些任务? 我开始单独做这个,但我必须进行额外的查询才能实现。 例如 events = Event.as(:e).where(“(( e.date_start – {current_time} )/{one_day_p}) < 1 ").users(:u, :rel).where("rel.reminded = {reminded_p}" ).params(reminded_p: false, one_day_p: one_day, current_time: time).pluck(:e) 然后我必须 events.each do […]

Neo4Jgem – 拯救未申报的关系

我正在尝试在两个节点之间创建一个实现,如下所述https://github.com/neo4jrb/neo4j/wiki/Neo4j-v3-Declared-Relationships from_node.create_rel(“FRIENDS”, to_node) 我得到一个未定义的create_rel方法 我究竟做错了什么? 我正在尝试在另一个模型中创建一个Q + A系统。 因此,问题和答案现在都被视为模型。 我正在为#获取一个undefined method create_rel’ event.rb has_many :out, :event_questions event_question.rb has_one :in, :events has_many :out, :event_answers def create_questions_of(from_node,to_node) from_node.create_rel(“questions_of”, to_node) end event_answer.rb has_one :in, :event_questions event_questions_controller.rb def new #is this needed end def create @event_question = EventQuestion.new(event_question_params) if @event_question.save @event = Event.find(params[:id]) @event_question.update(admin: current_user.facebook_id) @event_question.create_questions_of(self,@event) redirect_to @event else […]

Neo4j gem – 处理管理关系的首选方法

这主要是一个设计/效率问题,但我想看看是否有一种首选方法来处理neo4j,而不是我在sql db中如何处理它。 现在我有2个模型 – user和event 。 我还有user和event之间的关系来表示他们将参加活动。 我想找出代表活动管理员的最佳方式。 换句话说,我希望能够查询用户所关注的事件。 一种方法是在用户和event之间创建一个名为admin_of的新关系。 另一种方法是创建参与关系的管理属性。 admin: true admin_of查询看起来很简单,但又增加了与db的关系。 它也可以在以后处理多个管理员。 后一种方式可以通过类似的东西来查询:(来自文档) EnrolledIn.where(since: 2002)所以我的搜索将包括admin: true 。 但是我不知道如何链接这个,因为我希望它只是朋友活动。 另一个查询通常基于节点而不是关系的属性。 后一种方法似乎是一种首选的方法,但查询它的正确方法是什么? 或者是第一种更简单的方法,即使它增加了额外的关系? 更新:我想出了类似的东西 result = Event.query_as(:event).match(“event<-[invite: INVITED]-(user: User)<-[:FRIENDS_WITH]-(user)").where(invite: {admin: /true/}).pluck(:event) 基于详细的查询 https://github.com/neo4jrb/neo4j/wiki/Search-and-Match 更新2 我现在有这个,但没有得到匹配。 什么是开始解决我的查询错误的最佳方法? current_user.friends.events.query_as(:event).match(“event<-[invite]-(user: User)<-[friends_with]-(user)").where(invite: {admin: true}, event: {detail: 'property'}).pluck(:event) 我的用户模型有 has_many :both, :events, model_class: ‘Event’, rel_class: ‘Invite’ 我的活动模型有 has_many :both, […]

Neo4j.rb中的方法“rel_length”不起作用。

我需要得到用户的“朋友的朋友”。 所以, friend(rel_length: 2)不起作用(忽略方法),返回朋友。 class User include Neo4j::ActiveNode … has_many :out, :friend, rel_class: Friend … end class Friend include Neo4j::ActiveRel from_class User to_class User type ‘friend’ property :activity, type: String property :relation, type: String property :token, type: String end

如何从现有的Rails 4应用程序中删除ActiveRecord?

我开始使用Ruby on Rails项目,其中包括一个带有ActiveRecord和Neography的简单推荐系统。 现在我发现了neo4j.rb ,它将大大简化我的生活。 🙂 我现在才知道,我可以创建一个没有ActiveRecord的新应用程序,如下所示: rails new xyz -O 我可以这样做,并将我的大部分文件/代码粘贴到该新项目中。 或者有更简单的方法吗? 我还在考虑是否有必要采取这一步骤。 是否可以并行使用neo4j.rb和ActiveRecord? 我正在考虑使用ActiveRecord和我在neo4j中的推荐系统运行身份validation系统(例如Devise)。 有没有人有这种方法的经验?

Neo4j.rb创造了独特的关系

这是我的Neo4j主动节点 class User include Neo4j::ActiveNode has_many :out, :following, type: :following, model_class: ‘User’ end john = User.find(:name => “John”) tom = User.find(:name => “Tom”) # create following relationship john –> tom john.following < 1 # again create the relationship john.following < 2 我想创造独特的关系。 为避免重复,我们必须在创建关系密码查询时使用create unique。 例: MATCH (root { name: ‘root’ }) CREATE UNIQUE (root)-[:LOVES]-(someone) RETURN […]