diff --git a/syncclient/client.py b/syncclient/client.py index c01cb84..98eb1db 100644 --- a/syncclient/client.py +++ b/syncclient/client.py @@ -197,6 +197,7 @@ def get_records(self, collection, full=True, ids=None, newer=None, sorts the output: "newest" - orders by last-modified time, largest first "index" - orders by the sortindex, highest weight first + "oldest" - orders by last-modified time, oldest first """ params = kwargs.pop('params', {}) if full: @@ -209,7 +210,7 @@ def get_records(self, collection, full=True, ids=None, newer=None, params['limit'] = limit if offset is not None: params['offset'] = offset - if sort is not None and sort in ('newest', 'index'): + if sort is not None and sort in ('newest', 'index', 'oldest'): params['sort'] = sort return self._request('get', '/storage/%s' % collection.lower(), diff --git a/tests/test_client.py b/tests/test_client.py index 2ee77ef..74c462d 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -334,6 +334,12 @@ def test_get_records_handles_sort_by_newest(self): 'get', '/storage/mycollection', params={'sort': 'newest', 'full': True}) + def test_get_records_handles_sort_by_oldest(self): + self.client.get_records('mycollection', sort='oldest') + self.client._request.assert_called_with( + 'get', '/storage/mycollection', + params={'sort': 'oldest', 'full': True}) + def test_get_records_handles_sort_by_index(self): self.client.get_records('mycollection', sort='index') self.client._request.assert_called_with(