Adds a total() method for length before pagination.