andreasronge (owner)

Revisions

gist: 217094 Download_button fork
public
Description:
How do I find All actors that acted in these 2 movies, or 3 movies?
Public Clone URL: git://gist.github.com/217094.git
Embed All Files: show embed
Text only #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require 'model' # from the example/imdb neo4j.rb example
 
class Actor
  def acted_in_cool_movies
      traverse.outgoing(:acted_in).find_all {|movie| movie.relationship?(:cool_movies, :incoming)}
  end
end
 
cool_movies = Node.new
all_cool_movies = [m1,m2] # m1,m2 are two movies - defined somewhere else
all_cool_movies.each {|movie| cool_movies.relationships.outgoing(:cool_movies) << movie}
cool_movies.traverse.outgoing(:cool_movies).incoming(:acted_in).depth(2).filter{ respond_to?(:acted_in_cool_movies) and acted_in_cool_movies.size == all_cool_movies.size}.each {|n| puts n}
 
 
# Simple solution but inefficient solution
m1.actors.to_a & m2.actors.to_a