【发布时间】:2015-01-07 09:57:21
【问题描述】:
这是我的 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
我怎样才能在 Neo4j.rb 中使用 Rails...?
提前谢谢..
【问题讨论】:
标签: ruby-on-rails ruby neo4j neo4j.rb nosql