英文:
result of cypher query on neoism golang
问题
我有一个函数用于删除“User”节点并返回删除的节点数量,但它总是返回-1。
func DeleteUser(userid int) (int, error) {
stmt := `
MATCH (u:User) WHERE u.userId = {userid} delete u RETURN count(u) ;
`
params := neoism.Props{"userid": userid}
res := -1
cq := neoism.CypherQuery{
Statement: stmt,
Parameters: params,
Result: &res,
}
err := conn.Cypher(&cq)
return res, err
}
英文:
I have a function to delete "User" node and return count deleted node, but it always return -1.
func DeleteUser(userid int) (int, error) {
stmt := `
MATCH (u:User) WHERE u.userId = {userid} delete u RETURN count(u) ;
`
params := neoism.Props{"userid": userid}
res := -1
cq := neoism.CypherQuery{
Statement: stmt,
Parameters: params,
Result: &res,
}
err := conn.Cypher(&cq)
return res, err
}
答案1
得分: 0
-
res必须是[]struct类型。
-
不要在查询的末尾使用";"。
stmt :=MATCH (u:User) WHERE u.userId = {userid} delete u RETURN count(u)
英文:
-
res must be of type []struct
-
Don't use ";" at the end of query.
stmt :=MATCH (u:User) WHERE u.userId = {userid} delete u RETURN count(u)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论