cult-of-coders/grapher

Allow $paginated queries to return the count along with the result

Opened this issue · 0 comments

When you paginate a query, you usually want to know how many documents are left, or how many are available in total (when showing a pagination widget in a table for example).

To do this right now, the client needs to do 2 round-trips, and run the firewall twice, to get both info.

It would be interesting if the query could return the total count along with the results, for example:

  const cursor = Users.find(query, options);

  const results = cursor.fetch();

  if (options.limit) {
    const count = cursor.count();
    results._queryCount = count;
  }

  return results;

Maybe this is something that I could build in the meteor collections by default, instead of making grapher do this.