diegogub / aranGO

Golang driver for ArangoDB
Apache License 2.0
125 stars 31 forks source link

Total item count #22

Open PascalLeMerrer opened 8 years ago

PascalLeMerrer commented 8 years ago

How could I get the total number of items when I get a subset using the limit parameter? The fullcount property is always 0, event when the AQL request contains a "LIMIT" clause.

diegogub commented 8 years ago

Hello @PascalLeMerrer , I added a function to set fullCount option: https://gowalker.org/github.com/diegogub/aranGO#Query_SetFullCount

I'm working in a v2 release, with much more intuitive api, hopefully I will be able to finish it in a few weeks, as I'm very busy with work ! I will keep you updated if you want

Regards

PascalLeMerrer commented 8 years ago

Many thanks! I'm very interested in this V2, and my have a few suggestions. Should I create a new issue about them?

PascalLeMerrer commented 8 years ago

It doesn't seem to work. Maybe it's a usage problem on my side? My code is something like:

    queryString := "FOR u in users  SORT u.createdAt DESC LIMIT 0, 20 RETURN u"
    arangoQuery := ara.NewQuery(queryString)
    arangoQuery.SetFullCount(true)
    cursor, err := config.Db().Execute(arangoQuery)

    if err != nil {
        fmt.Println(err)
        return nil, 0, err
    }
    result := make([]User, len(cursor.Result))
    err = cursor.FetchBatch(&result)
    if err != nil {
        fmt.Println(err)
        return nil, 0, err
    }
    return result, cursor.FullCount(), nil
PascalLeMerrer commented 8 years ago

The problem is in the unmarshalling of the response of the database. The fullcount field is not in extra, but in extra.stats. I will make a pull request with a fix.