qena-shared-lib 0.1.20__py3-none-any.whl → 0.1.22__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -388,25 +388,28 @@ class RepositoryBase(Generic[T]):
388
388
  session: AsyncClientSession | None = None,
389
389
  ) -> T | P | None:
390
390
  if projection is not None:
391
- return projection.from_raw_projected_document(
392
- await self.collection.find_one(
393
- filter=filter,
394
- projection=projection.get_projection(),
395
- skip=skip,
396
- sort=sort,
397
- session=session or self.session,
398
- )
391
+ document = await self.collection.find_one(
392
+ filter=filter,
393
+ projection=projection.get_projection(),
394
+ skip=skip,
395
+ sort=sort,
396
+ session=session or self.session,
399
397
  )
400
-
401
- return self.document_type.from_raw_document(
402
- await self.collection.find_one(
398
+ else:
399
+ document = await self.collection.find_one(
403
400
  filter=filter,
404
- projection=projection,
405
401
  skip=skip,
406
402
  sort=sort,
407
403
  session=session or self.session,
408
404
  )
409
- )
405
+
406
+ if document is None:
407
+ return None
408
+
409
+ if projection is not None:
410
+ return projection.from_raw_projected_document(document)
411
+
412
+ return self.document_type.from_raw_document(document)
410
413
 
411
414
  async def replace(
412
415
  self, replacement: T, session: AsyncClientSession | None = None
@@ -584,16 +587,40 @@ class RepositoryBase(Generic[T]):
584
587
 
585
588
  return cast(int, await self.collection.estimated_document_count())
586
589
 
587
- async def aggregate(
590
+ @overload
591
+ def aggregate(
588
592
  self,
593
+ *,
589
594
  aggregation: type[A],
590
595
  let: dict[str, Any] | None = None,
591
596
  session: AsyncClientSession | None = None,
592
597
  ) -> AsyncGenerator[A, None]:
598
+ pass
599
+
600
+ @overload
601
+ def aggregate(
602
+ self,
603
+ *,
604
+ aggregation: type[A],
605
+ pipeline: list[Any],
606
+ let: dict[str, Any] | None = None,
607
+ session: AsyncClientSession | None = None,
608
+ ) -> AsyncGenerator[A, None]:
609
+ pass
610
+
611
+ async def aggregate(
612
+ self, *_: Any, **kwarg: Any
613
+ ) -> AsyncGenerator[Any, None]:
614
+ aggregation = cast(AggregatedDocument, kwarg.get("aggregation"))
615
+ pipeline = kwarg.get("pipeline")
616
+
617
+ if pipeline is None:
618
+ pipeline = aggregation.get_pipeline()
619
+
593
620
  async with await self.collection.aggregate(
594
- pipeline=aggregation.get_pipeline(),
595
- let=let,
596
- session=session or self.session,
621
+ pipeline=pipeline,
622
+ let=kwarg.get("let"),
623
+ session=kwarg.get("session") or self.session,
597
624
  ) as cursor:
598
625
  async for document in cursor:
599
626
  yield aggregation.from_raw_aggregated_document(document)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: qena-shared-lib
3
- Version: 0.1.20
3
+ Version: 0.1.22
4
4
  Summary: A shared tools for other services
5
5
  Requires-Dist: fastapi[all]==0.115.6
6
6
  Requires-Dist: prometheus-client==0.21.1
@@ -21,7 +21,7 @@ qena_shared_lib/kafka/_consumer.py,sha256=aEOtAqMhFPIMYbKK_BMDwR2rd_eaDzBJ6xR3Ud
21
21
  qena_shared_lib/kafka/_exception_handlers.py,sha256=D7Xh5eSpSkumQKvPfBmVB_E6vQxD58y41bFpP5Jzhqk,4084
22
22
  qena_shared_lib/kafka/_producer.py,sha256=QtYfKzNtxeIT1EtGpS-tvFC342oPoleF1AOl20LfNXs,3941
23
23
  qena_shared_lib/logging.py,sha256=HZiqbXpmJsAI7hheAaQ9EA8uj9yU0pMVCg64d_V0wzA,1748
24
- qena_shared_lib/mongodb.py,sha256=CHkegKThenGB4A9bb0wNMLYGdrGo8-jDMx_3wRngIJ4,17056
24
+ qena_shared_lib/mongodb.py,sha256=tlrmXxDae5IOZz-alL559ySKpRrTTQvOGFGB2QdJ5Ww,17701
25
25
  qena_shared_lib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
26
  qena_shared_lib/rabbitmq/__init__.py,sha256=g15fP9XQ1CHFBXZmeAxQcsppQ0Nx62gJ4VOK8nzW7T4,1254
27
27
  qena_shared_lib/rabbitmq/_base.py,sha256=pKJL0PNrhUOXw4XUJ1iZsuCPVY3ykvO8ebIfeX9HwXo,21502
@@ -45,6 +45,6 @@ qena_shared_lib/scheduler.py,sha256=Spp5PnpFJ0U4aLeFCNmje9zUA4zwkL-b7X8SSGkGssM,
45
45
  qena_shared_lib/security.py,sha256=RAXBkfhytJl-2SOXYQTJMnUb789-8DNZKRjRtpod16Y,6372
46
46
  qena_shared_lib/sync.py,sha256=79aGGWGYg_oGY9jTav1kghD8BSRY-_oNYdx3tuExr20,2541
47
47
  qena_shared_lib/utils.py,sha256=crD8NJD1Se7ZHPCaQBCi3c7Y46lMvk8OsN_bZTbcyto,1184
48
- qena_shared_lib-0.1.20.dist-info/WHEEL,sha256=k57ZwB-NkeM_6AsPnuOHv5gI5KM5kPD6Vx85WmGEcI0,78
49
- qena_shared_lib-0.1.20.dist-info/METADATA,sha256=NXMw-mncYxD5lp76H1gsdJpqoOTmwYldBIkxyXMYNfo,19281
50
- qena_shared_lib-0.1.20.dist-info/RECORD,,
48
+ qena_shared_lib-0.1.22.dist-info/WHEEL,sha256=k57ZwB-NkeM_6AsPnuOHv5gI5KM5kPD6Vx85WmGEcI0,78
49
+ qena_shared_lib-0.1.22.dist-info/METADATA,sha256=e-RJxza3kT6NvTVgU4z-ZPNppAjKd35vCjkBWeNwjNI,19281
50
+ qena_shared_lib-0.1.22.dist-info/RECORD,,