这是我的 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 << tom
# check count
john.following.count
#=> 1
# again create the relationship
john.following << tom
# again check count
john.following.count
#=> 2
我想建立独特的关系。
为了避免重复,我们必须在创建关系密码查询时使用 create unique。
例子:
MATCH (root { name: 'root' })
CREATE UNIQUE (root)-[:LOVES]-(someone)
RETURN someone
参考: http: //neo4j.com/docs/stable/query-create-unique.html
我如何使用 Rails 在 Neo4j.rb 中做到这一点......?
提前致谢..