Raj Adroit
Raj Adroit

Reputation: 3888

neo4j.rb check relation already exists between two nodes

I Need to check relation between two nodes exists already.

brian.following << chris
brian.following
#=> chris

I Need to check like this

brian.following?(chris)
#=> true
brian.following?(john)
#=> false
  1. Any method is there in neo4j.rb for this?

  2. if not, How can i write my custom method for this in Neo4j.rb-Rails ?

Upvotes: 1

Views: 426

Answers (1)

subvertallchris
subvertallchris

Reputation: 5482

You can do brian.following.include?(chris). Check out https://github.com/neo4jrb/neo4j/wiki/Optimized-Methods, it details this and many other helpful methods that are either modified versions of those found in Enumerable and unique to QueryProxy. You'll also find examples of these in https://github.com/neo4jrb/neo4j/blob/master/spec/e2e/query_proxy_methods_spec.rb.

Upvotes: 4

Related Questions