在neoism golang上的Cypher查询结果

huangapple go评论114阅读模式
英文:

result of cypher query on neoism golang

问题

我有一个函数用于删除“User”节点并返回删除的节点数量,但它总是返回-1。

  1. func DeleteUser(userid int) (int, error) {
  2. stmt := `
  3. MATCH (u:User) WHERE u.userId = {userid} delete u RETURN count(u) ;
  4. `
  5. params := neoism.Props{"userid": userid}
  6. res := -1
  7. cq := neoism.CypherQuery{
  8. Statement: stmt,
  9. Parameters: params,
  10. Result: &res,
  11. }
  12. err := conn.Cypher(&cq)
  13. return res, err
  14. }
英文:

I have a function to delete "User" node and return count deleted node, but it always return -1.

  1. func DeleteUser(userid int) (int, error) {
  2. stmt := `
  3. MATCH (u:User) WHERE u.userId = {userid} delete u RETURN count(u) ;
  4. `
  5. params := neoism.Props{"userid": userid}
  6. res := -1
  7. cq := neoism.CypherQuery{
  8. Statement: stmt,
  9. Parameters: params,
  10. Result: &res,
  11. }
  12. err := conn.Cypher(&cq)
  13. return res, err
  14. }

答案1

得分: 0

  1. res必须是[]struct类型。

  2. 不要在查询的末尾使用";"。
    stmt := MATCH (u:User) WHERE u.userId = {userid} delete u RETURN count(u)

英文:
  1. res must be of type []struct

  2. Don't use ";" at the end of query.
    stmt := MATCH (u:User) WHERE u.userId = {userid} delete u RETURN count(u)

huangapple
  • 本文由 发表于 2017年1月4日 11:17:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/41455686.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定