Pagination in Couchbase Server

To implement pagination in Couchbase Server, I added LIMIT and OFFSET in the original subquery. i.e.

select * from bucket where docType=“searchCiteria” LIMIT= OFFESET=
But I also want total number of records. I couldn’t find a way to do these 2 operations in one go. So I had to hit couchbase 2 times.

Is there any way to do that in 1 go?

There is no simple way to do it.

If you haven’t thought of this already, you could use UNION ALL.

select count(*) total_count from `beer-sample` where type = 'beer'
(select blah from `beer-sample` where type = 'beer' LIMIT 10 OFFSET 100);