Method: Cloudant::Client#bookmark_query

Defined in:
lib/cloudant/client.rb

#bookmark_query(q, &blk) ⇒ Object

Paginate query results - best for large volume. TODO: add feature that allows users to view previous pages and generally move into own class.



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/cloudant/client.rb', line 199

def bookmark_query(q,&blk)
  response = query(q)
  bookmark = response["bookmark"]
  docs     = response["docs"]

  until !docs || docs.empty?
    yield docs
    q["bookmark"] = bookmark
    response      = query(q)
    bookmark      = response["bookmark"]
    docs          = response["docs"]
  end

  docs
end