I'm trying to get the number of records of one table, but it doesn't return any value. I've tried in Rethinkdb Console and the query returns the results I want. The code is:
type OcorrenciasContagem struct {
TipoOcorrencia string
Contagem int
}
ocorrenciasContagem := []OcorrenciasContagem{}
res, err := r.Table("smpcRegistoOcorrencias").Group("tipoOcorrencia").Filter(func(row r.Term) r.Term {
return row.Field("dataOcorrencia").Match("^2018")
}).Count().Run(session.Sessions)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
err = res.All(&ocorrenciasContagem)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%+v",ocorrenciasContagem)
The result I have is {TipoOcorrencia: Contagem:0} {TipoOcorrencia: Contagem:0}
I expect, for example: { "group": "Apoio às Forças de Segurança" , "reduction": 1 } , { "group": "Busca e Resgate Terrestre de Animais" , "reduction": 1 }