aranGO icon indicating copy to clipboard operation
aranGO copied to clipboard

Total item count

Open PascalLeMerrer opened this issue 9 years ago • 4 comments

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.

PascalLeMerrer avatar Dec 08 '15 19:12 PascalLeMerrer

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

diegogub avatar Dec 09 '15 04:12 diegogub

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

PascalLeMerrer avatar Dec 09 '15 07:12 PascalLeMerrer

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 avatar Dec 09 '15 08:12 PascalLeMerrer

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.

PascalLeMerrer avatar Dec 10 '15 22:12 PascalLeMerrer