couchbase/couchbase-lite-ios — pull request #421 by pasin (2014-08-16 00:00:14+00:00)
Title: Fixes #163 REST total_rows should return number of rows in the view

* Add total_docs column to views table and set its default value to -1 (means 'unknown' for the old version of the api that do not have this fix)

* Add totalDocs property to CBLView() category. The totalDocs property will first try to get the value from views.total_docs columns and if the value is '-1', it will count the number of docs from the maps table, update the value to views.total_docs and return.

* Update the views.total_rows every time when the view's index is updated.

* Update CBL_Router's handler to return view.totalDocs for the total_rows attribute in query responses.

* Add CBL_View_TotalDocs test case and fix CBL_Router_Views accordingly.