Neo4jrb Neo4j::Session::CypherError: uuid not defined
Neo4jrb Neo4j::Session::CypherError: uuid not defined
我尝试使用 find 创建自定义 getOrCreate 方法,如果没有返回任何内容,则使用 create
我的 class :
class User
include Neo4j::ActiveNode
include Neo4jrbConcern
property :name
property :email
validates :name, :presence => true
validates :email, :presence => true
end
getOrCreate方法继承自关注点
def getOrCreate(params)
obj = self.find(params)
if obj
puts 'obj found : ' + obj
return obj
else
return self.create(params)
end
end
我正在尝试这个:
User.getOrCreate(
name: data['name'],
email: data['email']
)
结果是这个错误:
Neo4j::Session::CypherError: uuid not defined (line 1, column 86)
"MATCH (result_user:`User`) WHERE result_user.uuid.name = {result_user_uuid_name} AND uuid.email = {result_user_uuid_email} RETURN result_user ORDER BY ID(result_user) LIMIT {limit_1}"
^
/Users/xxx/.rvm/gems/ruby-2.1.5/gems/neo4j-core-4.0.0/lib/neo4j-server/cypher_response.rb:166:in `raise_cypher_error'
/Users/xxx/.rvm/gems/ruby-2.1.5/gems/neo4j-core-4.0.0/lib/neo4j-core/query.rb:164:in `response'
/Users/xxx/.rvm/gems/ruby-2.1.5/gems/neo4j-core-4.0.0/lib/neo4j-core/query.rb:205:in `pluck'
你看到我哪里做错了吗?
谢谢!
伯努瓦
你不能像那样将哈希传递给 find
。它应该是这样的:
def getOrCreate(params)
obj = self.where(params).first
if obj
puts 'obj found : ' + obj
return obj
else
return self.create(params)
end
end
虽然这似乎也是使用密码的完美案例 MERGE
,这意味着您只需要执行一个查询。
我尝试使用 find 创建自定义 getOrCreate 方法,如果没有返回任何内容,则使用 create
我的 class :
class User
include Neo4j::ActiveNode
include Neo4jrbConcern
property :name
property :email
validates :name, :presence => true
validates :email, :presence => true
end
getOrCreate方法继承自关注点
def getOrCreate(params)
obj = self.find(params)
if obj
puts 'obj found : ' + obj
return obj
else
return self.create(params)
end
end
我正在尝试这个:
User.getOrCreate(
name: data['name'],
email: data['email']
)
结果是这个错误:
Neo4j::Session::CypherError: uuid not defined (line 1, column 86)
"MATCH (result_user:`User`) WHERE result_user.uuid.name = {result_user_uuid_name} AND uuid.email = {result_user_uuid_email} RETURN result_user ORDER BY ID(result_user) LIMIT {limit_1}"
^
/Users/xxx/.rvm/gems/ruby-2.1.5/gems/neo4j-core-4.0.0/lib/neo4j-server/cypher_response.rb:166:in `raise_cypher_error'
/Users/xxx/.rvm/gems/ruby-2.1.5/gems/neo4j-core-4.0.0/lib/neo4j-core/query.rb:164:in `response'
/Users/xxx/.rvm/gems/ruby-2.1.5/gems/neo4j-core-4.0.0/lib/neo4j-core/query.rb:205:in `pluck'
你看到我哪里做错了吗?
谢谢!
伯努瓦
你不能像那样将哈希传递给 find
。它应该是这样的:
def getOrCreate(params)
obj = self.where(params).first
if obj
puts 'obj found : ' + obj
return obj
else
return self.create(params)
end
end
虽然这似乎也是使用密码的完美案例 MERGE
,这意味着您只需要执行一个查询。