diff --git a/wrappers/python/aries_askar/bindings/__init__.py b/wrappers/python/aries_askar/bindings/__init__.py index 065a8273e..d7b5f7e9f 100644 --- a/wrappers/python/aries_askar/bindings/__init__.py +++ b/wrappers/python/aries_askar/bindings/__init__.py @@ -455,17 +455,21 @@ async def scan_start( tag_filter: Optional[Union[str, dict]] = None, offset: Optional[int] = None, limit: Optional[int] = None, + order_by: Optional[str] = None, + descending: bool = False, ) -> ScanHandle: """Create a new Scan against the Store.""" return await invoke_async( "askar_scan_start", - (StoreHandle, FfiStr, FfiStr, FfiJson, c_int64, c_int64), + (StoreHandle, FfiStr, FfiStr, FfiJson, c_int64, c_int64, FfiStr, c_int8), handle, profile, category, tag_filter, offset or 0, limit if limit is not None else -1, + order_by, + descending, return_type=ScanHandle, ) diff --git a/wrappers/python/aries_askar/store.py b/wrappers/python/aries_askar/store.py index f92002a6b..c68253703 100644 --- a/wrappers/python/aries_askar/store.py +++ b/wrappers/python/aries_askar/store.py @@ -247,9 +247,20 @@ def __init__( tag_filter: Union[str, dict] = None, offset: int = None, limit: int = None, + order_by: Optional[str] = None, + descending: bool = False, ): """Initialize the Scan instance.""" - self._params = (store, profile, category, tag_filter, offset, limit) + self._params = ( + store, + profile, + category, + tag_filter, + offset, + limit, + order_by, + descending, + ) self._handle: ScanHandle = None self._buffer: IterEntryList = None @@ -265,14 +276,30 @@ def __aiter__(self): async def __anext__(self): """Fetch the next scan result during async iteration.""" if self._handle is None: - (store, profile, category, tag_filter, offset, limit) = self._params + ( + store, + profile, + category, + tag_filter, + offset, + limit, + order_by, + descending, + ) = self._params self._params = None if not store.handle: raise AskarError( AskarErrorCode.WRAPPER, "Cannot scan from closed store" ) self._handle = await bindings.scan_start( - store.handle, profile, category, tag_filter, offset, limit + store.handle, + profile, + category, + tag_filter, + offset, + limit, + order_by, + descending, ) list_handle = await bindings.scan_next(self._handle) self._buffer = iter(EntryList(list_handle)) if list_handle else None @@ -428,9 +455,13 @@ def scan( offset: int = None, limit: int = None, profile: str = None, + order_by: Optional[str] = None, + descending: bool = False, ) -> Scan: """Start a new record scan.""" - return Scan(self, profile, category, tag_filter, offset, limit) + return Scan( + self, profile, category, tag_filter, offset, limit, order_by, descending + ) def session(self, profile: str = None) -> "OpenSession": """Open a new session on the store without starting a transaction."""