Pagination with counters

How can I get count of all entities founded by name when I do need only a part of it?

I needed something like that:

all as var(func: regexp(entityName, /some name/)){}

entities(func: uid(all), first: 5,offset:10) {
  uid
  entityName
  ...
}

counters(){
  total: count(all)
}

Dgraph: 1.0.4

Did you try something like the below?

all as counters(func: regexp(entityName, /some name/)){
  total: count(uid)
}

entities(func: uid(all), first: 5,offset:10) {
  uid
  entityName
  ...
}
2 Likes

Ye, I get something like that: {“counters”:[{“total”:5}],}. That’s what I need, Thx. But why “total” must be in array?

We return an array irrespective of the number of objects (1 or more), so that clients can expect a standard interface while parsing the response.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.