Created
December 3, 2009 18:02
-
-
Save simonw/248372 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def all_from_view(db, view_name, batch_size=100): | |
| kwargs = { | |
| 'limit': batch_size, | |
| 'include_docs': True, | |
| } | |
| startkey_docid = None | |
| last_served_id = None | |
| while True: | |
| if startkey_docid is not None: | |
| kwargs['startkey_docid'] = startkey_docid | |
| kwargs['startkey'] = True | |
| print 'Kwargs: %s' % kwargs | |
| vr = db.view(view_name, **kwargs) | |
| if not vr.rows: | |
| break | |
| for row in vr.rows: | |
| if row.id != last_served_id: | |
| yield row | |
| last_served_id = row.id | |
| startkey_docid = vr.rows[-1]['id'] | |
| print 'startkey_docid now %s' % startkey_docid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment