johnnadratowski / golang-neo4j-bolt-driver

Golang Bolt driver for Neo4j
MIT License
213 stars 72 forks source link

Deletion of nonexisting nodes. #62

Open Ragnar-BY opened 5 years ago

Ragnar-BY commented 5 years ago

I have next code:

DeleteNodes = "MATCH (n) DETACH DELETE n;"
func (s *Service) cleanUp(storage bolt.Conn) error {
    result, err := storage.ExecNeo(DeleteNodes, nil)
    if err != nil {
        return fmt.Errorf("bad DELETE request")
    }
    numResult, err := result.RowsAffected()
    if err != nil {
        return err
    }
    fmt.Printf("Rows Deleted: %d", numResult)
    return nil
}

This code works well but only if database is not null. If there are not nodes in database, then I get error Unrecognized type for stats metadata: map[string]interface {}{"result_consumed_after":0, "type":"w"} in function result.RowsAffected() In my opinion we should not get error here.