Spraypaint the isomorphic, framework-agnostic Graphiti ORM

Statistics

Use #stats() to request statistics. Access stats within meta:

Typescript
Javascript
let { data } = await Post.stats({ total: "count" }).all()
data.meta.stats.total.count // the total count
Post.stats({ total: "count" }).all().then(function(response) {
  response.meta.stats.total.count // the total count
})

/posts?stats[total]=count

Stats are always independent of pagination. If you request the total count, you’ll get the total count even if you’re limiting to 10 per page. This means to get only statistics - avoid returning Post instances altogether - simply request 0 results per page:

Typescript
Javascript
let { data } = await Post.per(0)stats({ total: "count" }).all()
data.meta.stats.total.count // the total count
Post
  .per(0)
  .stats({ total: "count" })
  .all().then(function(response) {
    response.meta.stats.total.count // the total count
  })

/posts?stats[total]=count&page[size]=0