Neo4j的宝石 - 从数组对象查询 [英] Neo4j gem - Querying from an array object
问题描述
在我的previous例如我有此查询
In my previous example I had this query
current_user.friends.events(:事件:REL)。凡(rel.admin = {} admin_p和event.detail = {} detail_p)PARAMS(admin_p:真实,detail_p :真).pluck(:事件)
current_user.friends.events
带给我最多的事件继续我的链条,但是,这工作如果我已经有一个包含事件的数组对象?
current_user.friends.events
brings me up to events to continue my chain, but does this work for if I already have an object that contains an array of events?
在我的例子中,我试图使用地理codeR靠近拉。
In my example, I am trying to use geocoder to pull in proximity.
所以,我有我的用户,哪些是地缘codeD的事件。
So I have my user and events which are geocoded.
地理codeR可以做这样的事情。
Geocoder can do something like this
Venue.near([40.71,100.23],20)
#20找到英里范围内的所有OBJ文件
Venue.near([40.71, 100.23], 20)
# find all objs within 20 miles
所以,我基本上可以找到所有的事件,并将其存储在一个对象。现在我可以用Neo4j的查询过滤的对象?
So I can essentially find all the events and store it in an object. Now can I use the neo4j query to filter that object?
例如。
array_object(:事件:REL)。凡(rel.admin = {} admin_p和event.detail = {} detail_p)PARAMS(admin_p:真,detail_p:真)。采摘(:事件)
即使这个工程,是否有替代办法做到这一点?
Even if this works, is there an alternate way to do this?
推荐答案
您不能调用阵列上查询代理方法,所以只要抓住这些事件的ID,并相应地过滤匹配。
You can't call query proxy methods on an array, so just grab the IDs of those events and filter your match accordingly.
current_user.friends.events(:e).where(neo_id: array_object.map { |e| e.neo_id })
这会过滤是数组中的用户好友的活动。我们可以使用 neo_id
在其中,
获得更好的性能。
That'll filter the user's friends' events that are in that array. We can use neo_id
in where
for better performance.
这篇关于Neo4j的宝石 - 从数组对象查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!