@@ -545,6 +545,32 @@ final class ZQuery[-R, +E, +A] private (private val step: ZIO[R, Nothing, Result
545
545
}
546
546
)
547
547
548
+ /**
549
+ * Extracts the optional value or succeeds with the given 'default' value.
550
+ */
551
+ def someOrElse [B ](default : => B )(implicit ev : A <:< Option [B ], trace : ZTraceElement ): ZQuery [R , E , B ] =
552
+ self.map(_.getOrElse(default))
553
+
554
+ /**
555
+ * Extracts the optional value or executes the given 'default' query.
556
+ */
557
+ @ deprecated(" use someOrElseZIO" , " 0.3.0" )
558
+ final def someOrElseM [B , R1 <: R , E1 >: E ](
559
+ default : ZQuery [R1 , E1 , B ]
560
+ )(implicit ev : A <:< Option [B ], trace : ZTraceElement ): ZQuery [R1 , E1 , B ] =
561
+ someOrElseZIO(default)
562
+
563
+ /**
564
+ * Extracts the optional value or executes the given 'default' query.
565
+ */
566
+ final def someOrElseZIO [B , R1 <: R , E1 >: E ](
567
+ default : ZQuery [R1 , E1 , B ]
568
+ )(implicit ev : A <:< Option [B ], trace : ZTraceElement ): ZQuery [R1 , E1 , B ] =
569
+ self.flatMap(ev(_) match {
570
+ case Some (value) => ZQuery .succeed(value)
571
+ case None => default
572
+ })
573
+
548
574
/**
549
575
* Extracts the optional value or fails with the given error `e`.
550
576
*/
@@ -883,6 +909,40 @@ object ZQuery {
883
909
): ZQuery [R , E , Collection [A ]] =
884
910
foreach(as)(identity)
885
911
912
+ /**
913
+ * Collects a collection of queries into a query returning a collection of
914
+ * their results. Requests will be executed sequentially and will be
915
+ * pipelined.
916
+ */
917
+ def collectAll [R , E , A ](as : Set [ZQuery [R , E , A ]])(implicit trace : ZTraceElement ): ZQuery [R , E , Set [A ]] =
918
+ foreach(as)(identity)
919
+
920
+ /**
921
+ * Collects a collection of queries into a query returning a collection of
922
+ * their results. Requests will be executed sequentially and will be
923
+ * pipelined.
924
+ */
925
+ def collectAll [R , E , A : ClassTag ](as : Array [ZQuery [R , E , A ]])(implicit trace : ZTraceElement ): ZQuery [R , E , Array [A ]] =
926
+ foreach(as)(identity)
927
+
928
+ /**
929
+ * Collects a collection of queries into a query returning a collection of
930
+ * their results. Requests will be executed sequentially and will be
931
+ * pipelined.
932
+ */
933
+ def collectAll [R , E , A ](as : Option [ZQuery [R , E , A ]])(implicit trace : ZTraceElement ): ZQuery [R , E , Option [A ]] =
934
+ foreach(as)(identity)
935
+
936
+ /**
937
+ * Collects a collection of queries into a query returning a collection of
938
+ * their results. Requests will be executed sequentially and will be
939
+ * pipelined.
940
+ */
941
+ def collectAll [R , E , A ](as : NonEmptyChunk [ZQuery [R , E , A ]])(implicit
942
+ trace : ZTraceElement
943
+ ): ZQuery [R , E , NonEmptyChunk [A ]] =
944
+ foreach(as)(identity)
945
+
886
946
/**
887
947
* Collects a collection of queries into a query returning a collection of
888
948
* their results, batching requests to data sources.
@@ -895,6 +955,31 @@ object ZQuery {
895
955
): ZQuery [R , E , Collection [A ]] =
896
956
foreachBatched(as)(identity)
897
957
958
+ /**
959
+ * Collects a collection of queries into a query returning a collection of
960
+ * their results, batching requests to data sources.
961
+ */
962
+ def collectAllBatched [R , E , A ](as : Set [ZQuery [R , E , A ]])(implicit trace : ZTraceElement ): ZQuery [R , E , Set [A ]] =
963
+ foreachBatched(as)(identity)
964
+
965
+ /**
966
+ * Collects a collection of queries into a query returning a collection of
967
+ * their results, batching requests to data sources.
968
+ */
969
+ def collectAllBatched [R , E , A : ClassTag ](as : Array [ZQuery [R , E , A ]])(implicit
970
+ trace : ZTraceElement
971
+ ): ZQuery [R , E , Array [A ]] =
972
+ foreachBatched(as)(identity)
973
+
974
+ /**
975
+ * Collects a collection of queries into a query returning a collection of
976
+ * their results, batching requests to data sources.
977
+ */
978
+ def collectAllBatched [R , E , A ](as : NonEmptyChunk [ZQuery [R , E , A ]])(implicit
979
+ trace : ZTraceElement
980
+ ): ZQuery [R , E , NonEmptyChunk [A ]] =
981
+ foreachBatched(as)(identity)
982
+
898
983
/**
899
984
* Collects a collection of queries into a query returning a collection of
900
985
* their results. Requests will be executed in parallel and will be batched.
@@ -907,6 +992,31 @@ object ZQuery {
907
992
): ZQuery [R , E , Collection [A ]] =
908
993
foreachPar(as)(identity)
909
994
995
+ /**
996
+ * Collects a collection of queries into a query returning a collection of
997
+ * their results. Requests will be executed in parallel and will be batched.
998
+ */
999
+ def collectAllPar [R , E , A ](as : Set [ZQuery [R , E , A ]])(implicit trace : ZTraceElement ): ZQuery [R , E , Set [A ]] =
1000
+ foreachPar(as)(identity)
1001
+
1002
+ /**
1003
+ * Collects a collection of queries into a query returning a collection of
1004
+ * their results. Requests will be executed in parallel and will be batched.
1005
+ */
1006
+ def collectAllPar [R , E , A : ClassTag ](as : Array [ZQuery [R , E , A ]])(implicit
1007
+ trace : ZTraceElement
1008
+ ): ZQuery [R , E , Array [A ]] =
1009
+ foreachPar(as)(identity)
1010
+
1011
+ /**
1012
+ * Collects a collection of queries into a query returning a collection of
1013
+ * their results. Requests will be executed in parallel and will be batched.
1014
+ */
1015
+ def collectAllPar [R , E , A ](as : NonEmptyChunk [ZQuery [R , E , A ]])(implicit
1016
+ trace : ZTraceElement
1017
+ ): ZQuery [R , E , NonEmptyChunk [A ]] =
1018
+ foreachPar(as)(identity)
1019
+
910
1020
/**
911
1021
* Constructs a query that dies with the specified error.
912
1022
*/
0 commit comments