Skip to content

Commit 1502464

Browse files
committed
Add API for the update_seq option on view results (fixes #228)
1 parent 0178803 commit 1502464

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

couchdb/client.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ class ViewResults(object):
11501150
def __init__(self, view, options):
11511151
self.view = view
11521152
self.options = options
1153-
self._rows = self._total_rows = self._offset = None
1153+
self._rows = self._total_rows = self._offset = self._update_seq = None
11541154

11551155
def __repr__(self):
11561156
return '<%s %r %r>' % (type(self).__name__, self.view, self.options)
@@ -1179,6 +1179,7 @@ def _fetch(self):
11791179
self._rows = [wrapper(row) for row in data['rows']]
11801180
self._total_rows = data.get('total_rows')
11811181
self._offset = data.get('offset', 0)
1182+
self._update_seq = data.get('update_seq')
11821183

11831184
@property
11841185
def rows(self):
@@ -1214,6 +1215,20 @@ def offset(self):
12141215
self._fetch()
12151216
return self._offset
12161217

1218+
@property
1219+
def update_seq(self):
1220+
"""The database update sequence that the view reflects.
1221+
1222+
The update sequence is included in the view result only when it is
1223+
explicitly requested using the `update_seq=true` query option.
1224+
Otherwise, the value is None.
1225+
1226+
:rtype: `int` or `NoneType` depending on the query options
1227+
"""
1228+
if self._rows is None:
1229+
self._fetch()
1230+
return self._update_seq
1231+
12171232

12181233
class Row(dict):
12191234
"""Representation of a row as returned by database views."""

0 commit comments

Comments
 (0)