4

我还没有真正的代码,但我的代码与我需要的相反

current_user.friends(:f).match_to(event)

这将返回与我的事件节点有关系的朋友。我需要的是那些没有这种关系的人。

我必须像在文档中那样喂它吗

blog.query_as(:blog).match("blog<-[:COMMENTS_ON]-(:Comment)<-[:AUTHORED]-(author:Person)").where("author.age > 30").pluck(:author)

但没有关系?

所以像

current_user.friends.query_as(:f).match("event<-[invite:invited]-(f:User)).where(invite: nil)

还是有其他方法?

4

1 回答 1

6

该查询不起作用,因为如果您在密码中指定 MATCH,则表示该关系必须存在。您需要做的是在 WHERE 子句中使用 match ascii 语法(neo4j 不情愿地支持这种情况):

current_user.friends.query_as(:friend).
  match(event: {neo_id: event.neo_id}).
  where("NOT(friend-[:invited]->(event:Event))").
  pluck(:friend)

在我看来,您应该能够match(event: event)在第二行上做。你也许可以,但我忘记了。

另请注意,这match_to适用于链中的最新关联(因此在您的第一个示例中,您将尝试将event对象与用户的一个朋友匹配,这是行不通的)。

于 2014-12-09T13:31:15.713 回答