File tree 2 files changed +14
-1
lines changed
core/src/main/scala/mongo4cats/collection/queries
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import com.mongodb.reactivestreams.client.{
32
32
import fs2 .Stream
33
33
import mongo4cats .helpers ._
34
34
import mongo4cats .bson .BsonDecoder
35
+ import mongo4cats .bson .BsonDecodeError
35
36
import mongo4cats .bson .syntax ._
36
37
import mongo4cats .client .ClientSession
37
38
import mongo4cats .collection .operations .Aggregate
@@ -59,6 +60,7 @@ trait WatchQueryBuilder[F[_]] {
59
60
60
61
//
61
62
def stream : Stream [F , ChangeStreamDocument [BsonValue ]]
63
+ def updateStreamAttempt [A : BsonDecoder ](onError : BsonDecodeError => F [Unit ]): Stream [F , A ]
62
64
def updateStream [A : BsonDecoder ]: Stream [F , A ]
63
65
64
66
def mapK [G [_]](f : F ~> G ): WatchQueryBuilder [G ]
@@ -120,6 +122,17 @@ object WatchQueryBuilder {
120
122
def stream =
121
123
boundedStreamF(1 ).translate(transform)
122
124
125
+ def updateStreamAttempt [A : BsonDecoder ](onError : BsonDecodeError => G [Unit ]) =
126
+ boundedStreamF(1 )
127
+ .map(_.getFullDocument.as[A ])
128
+ .translate(transform)
129
+ .flatMap {
130
+ case Left (decodeError) =>
131
+ Stream .exec(onError(decodeError))
132
+ case Right (elem) =>
133
+ Stream (elem)
134
+ }
135
+
123
136
def updateStream [A : BsonDecoder ] =
124
137
boundedStreamF(1 ).map(_.getFullDocument).evalMap(_.as[A ].liftTo[F ]).translate(transform)
125
138
Original file line number Diff line number Diff line change 1
- version in ThisBuild := " 0.6 .0"
1
+ version in ThisBuild := " 0.7 .0"
You can’t perform that action at this time.
0 commit comments