在neoism golang上的Cypher查询结果

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

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

  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:

确定