Skip to content

Commit

Permalink
fix first method in Fs2AggregateQueryBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
Bastien ESCOUVOIS committed Dec 15, 2023
1 parent b2e64ae commit 57284ea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private[collection] object Queries {
) extends AggregateQueryBuilder[F, T, Stream[F, *]] {

def toCollection: F[Unit] = applyQueries().toCollection.asyncVoid[F]
def first: F[Option[T]] = applyQueries().first().asyncSingle[F].unNone.map(Option.apply)
def first: F[Option[T]] = applyQueries().first().asyncSingle[F]
def all: F[Iterable[T]] = applyQueries().asyncIterable[F]
def stream: Stream[F, T] = applyQueries().stream[F]
def boundedStream(capacity: Int): Stream[F, T] = applyQueries().boundedStream[F](capacity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,24 @@ class MongoCollectionAggregateSpec extends AsyncWordSpec with Matchers with Embe
}
}
}

"using first, return none if no result is found" in {
withEmbeddedMongoDatabase { db =>
val result = for {
accs <- db.getCollection("accounts")
res <- accs
.aggregate[Document](
Aggregate
.matchBy(Filter.eq("currency", TestData.LVL))
)
.first
} yield res

result.map { res =>
res mustBe empty
}
}
}
}
}

Expand Down

0 comments on commit 57284ea

Please sign in to comment.