Module spring.data.mongodb
Interface ReactiveFindOperation.TerminatingFind<T>
- All Known Subinterfaces:
ReactiveFindOperation.FindWithCollection<T>,ReactiveFindOperation.FindWithProjection<T>,ReactiveFindOperation.FindWithQuery<T>,ReactiveFindOperation.ReactiveFind<T>
- Enclosing interface:
- ReactiveFindOperation
public static interface ReactiveFindOperation.TerminatingFind<T>
Compose find execution by calling one of the terminating methods.
-
Method Summary
Modifier and TypeMethodDescriptionall()Get all matching elements.count()Get the number of matching elements.exists()Check for the presence of matching elements.first()Get the first or no result.one()Get exactly zero or one result.scroll(ScrollPosition scrollPosition) Return a scroll of elements either starting or resuming atScrollPosition.tail()Get all matching elements using atailable cursor.
-
Method Details
-
one
Get exactly zero or one result.- Returns:
Mono.empty()if no match found. Never null.- Throws:
IncorrectResultSizeDataAccessException- if more than one match found.
-
first
Get the first or no result.- Returns:
Mono.empty()if no match found. Never null.
-
all
Get all matching elements.- Returns:
- never null.
-
scroll
Return a scroll of elements either starting or resuming atScrollPosition.When using
KeysetScrollPosition, make sure to use non-nullablesort propertiesas MongoDB does not support criteria to reconstruct a query result from absent document fields ornullvalues through$gt/$ltoperators.- Parameters:
scrollPosition- the scroll position.- Returns:
- a scroll of the resulting elements.
- Since:
- 4.1
- See Also:
-
tail
Get all matching elements using atailable cursor. The stream will not be completed unless theSubscriptioniscanceled.
However, the stream may become dead, or invalid, if either the query returns no match or the cursor returns the document at the "end" of the collection and then the application deletes that document.
A stream that is no longer in use must beDisposable.dispose()disposed} otherwise the streams will linger and exhaust resources.
NOTE: Requires a capped collection.- Returns:
- the
Fluxemitting converted objects. - Since:
- 2.1
-
count
Get the number of matching elements.
This method uses anaggregation executioneven for emptyquerieswhich may have an impact on performance, but guarantees shard, session and transaction compliance. In case an inaccurate count satisfies the applications needs useReactiveMongoOperations.estimatedCount(String)for empty queries instead.- Returns:
Monoemitting total number of matching elements. Never null.
-
exists
Check for the presence of matching elements.- Returns:
Monoemitting true if at least one matching element exists. Never null.
-