comparison sat/memory/sqla.py @ 3753:10b71e3526bd

core (memory/sqla): add attribute to filter on `item_ids` in `getItems`
author Goffi <goffi@goffi.org>
date Fri, 13 May 2022 17:58:51 +0200
parents 658ddbabaf36
children af485e8afe03
comparison
equal deleted inserted replaced
3752:5f546dd910e0 3753:10b71e3526bd
1222 @aio 1222 @aio
1223 async def getItems( 1223 async def getItems(
1224 self, 1224 self,
1225 node: PubsubNode, 1225 node: PubsubNode,
1226 max_items: Optional[int] = None, 1226 max_items: Optional[int] = None,
1227 item_ids: Optional[list[str]] = None,
1227 before: Optional[str] = None, 1228 before: Optional[str] = None,
1228 after: Optional[str] = None, 1229 after: Optional[str] = None,
1229 from_index: Optional[int] = None, 1230 from_index: Optional[int] = None,
1230 order_by: Optional[List[str]] = None, 1231 order_by: Optional[List[str]] = None,
1231 desc: bool = True, 1232 desc: bool = True,
1276 stmt = ( 1277 stmt = (
1277 select(PubsubItem) 1278 select(PubsubItem)
1278 .filter_by(node_id=node.id) 1279 .filter_by(node_id=node.id)
1279 .limit(max_items) 1280 .limit(max_items)
1280 ) 1281 )
1282
1283 if item_ids is not None:
1284 stmt = stmt.where(PubsubItem.name.in_(item_ids))
1281 1285
1282 if not order_by: 1286 if not order_by:
1283 order_by = [C.ORDER_BY_MODIFICATION] 1287 order_by = [C.ORDER_BY_MODIFICATION]
1284 1288
1285 order = [] 1289 order = []