T
- the operations result type.AsyncReadOperation<AsyncBatchCursor<T>>
, ReadOperation<BatchCursor<T>>
public class FindOperation<T> extends Object implements AsyncReadOperation<AsyncBatchCursor<T>>, ReadOperation<BatchCursor<T>>
Constructor | Description |
---|---|
FindOperation(MongoNamespace namespace,
Decoder<T> decoder) |
Construct a new instance.
|
Modifier and Type | Method | Description |
---|---|---|
ReadOperation<BsonDocument> |
asExplainableOperation(ExplainVerbosity explainVerbosity) |
Gets an operation whose execution explains this operation.
|
AsyncReadOperation<BsonDocument> |
asExplainableOperationAsync(ExplainVerbosity explainVerbosity) |
Gets an operation whose execution explains this operation.
|
FindOperation<T> |
batchSize(int batchSize) |
Sets the number of documents to return per batch.
|
FindOperation<T> |
collation(Collation collation) |
Sets the collation options
|
FindOperation<T> |
comment(String comment) |
Sets the comment to the query.
|
FindOperation<T> |
cursorType(CursorType cursorType) |
Sets the cursor type.
|
BatchCursor<T> |
execute(ReadBinding binding) |
General execute which can return anything of type T
|
void |
executeAsync(AsyncReadBinding binding,
SingleResultCallback<AsyncBatchCursor<T>> callback) |
General execute which can return anything of type T
|
FindOperation<T> |
filter(BsonDocument filter) |
Sets the query filter to apply to the query.
|
int |
getBatchSize() |
Gets the number of documents to return per batch.
|
Collation |
getCollation() |
Returns the collation options
|
String |
getComment() |
Returns the comment to send with the query.
|
CursorType |
getCursorType() |
Get the cursor type.
|
Decoder<T> |
getDecoder() |
Gets the decoder used to decode the result documents.
|
BsonDocument |
getFilter() |
Gets the query filter.
|
BsonDocument |
getHint() |
Returns the hint for which index to use.
|
int |
getLimit() |
Gets the limit to apply.
|
BsonDocument |
getMax() |
Returns the exclusive upper bound for a specific index.
|
long |
getMaxAwaitTime(TimeUnit timeUnit) |
The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor
query.
|
long |
getMaxScan() |
Returns the maximum number of documents or index keys to scan when executing the query.
|
long |
getMaxTime(TimeUnit timeUnit) |
Gets the maximum execution time on the server for this operation.
|
BsonDocument |
getMin() |
Returns the minimum inclusive lower bound for a specific index.
|
BsonDocument |
getModifiers() |
Gets the query modifiers to apply to this operation.
|
MongoNamespace |
getNamespace() |
Gets the namespace.
|
BsonDocument |
getProjection() |
Gets a document describing the fields to return for all matching documents.
|
ReadConcern |
getReadConcern() |
Gets the read concern
|
int |
getSkip() |
Gets the number of documents to skip.
|
BsonDocument |
getSort() |
Gets the sort criteria to apply to the query.
|
FindOperation<T> |
hint(BsonDocument hint) |
Sets the hint for which index to use.
|
boolean |
isNoCursorTimeout() |
Returns true if cursor timeout has been turned off.
|
boolean |
isOplogReplay() |
Internal replication use only.
|
boolean |
isPartial() |
Returns true if can get partial results from a mongos if some shards are down.
|
boolean |
isReturnKey() |
Returns the returnKey.
|
boolean |
isShowRecordId() |
Returns the showRecordId.
|
boolean |
isSlaveOk() |
Returns true if set to allowed to query non-primary replica set members.
|
boolean |
isSnapshot() |
Returns the snapshot.
|
FindOperation<T> |
limit(int limit) |
Sets the limit to apply.
|
FindOperation<T> |
max(BsonDocument max) |
Sets the exclusive upper bound for a specific index.
|
FindOperation<T> |
maxAwaitTime(long maxAwaitTime,
TimeUnit timeUnit) |
Sets the maximum await execution time on the server for this operation.
|
FindOperation<T> |
maxScan(long maxScan) |
Sets the maximum number of documents or index keys to scan when executing the query.
|
FindOperation<T> |
maxTime(long maxTime,
TimeUnit timeUnit) |
Sets the maximum execution time on the server for this operation.
|
FindOperation<T> |
min(BsonDocument min) |
Sets the minimum inclusive lower bound for a specific index.
|
FindOperation<T> |
modifiers(BsonDocument modifiers) |
Deprecated.
use the individual setters instead
|
FindOperation<T> |
noCursorTimeout(boolean noCursorTimeout) |
Sets if the cursor timeout should be turned off.
|
FindOperation<T> |
oplogReplay(boolean oplogReplay) |
Internal replication use only.
|
FindOperation<T> |
partial(boolean partial) |
Sets if partial results from a mongos if some shards are down are allowed
|
FindOperation<T> |
projection(BsonDocument projection) |
Sets a document describing the fields to return for all matching documents.
|
FindOperation<T> |
readConcern(ReadConcern readConcern) |
Sets the read concern
|
FindOperation<T> |
returnKey(boolean returnKey) |
Sets the returnKey.
|
FindOperation<T> |
showRecordId(boolean showRecordId) |
Sets the showRecordId.
|
FindOperation<T> |
skip(int skip) |
Sets the number of documents to skip.
|
FindOperation<T> |
slaveOk(boolean slaveOk) |
Sets if allowed to query non-primary replica set members.
|
FindOperation<T> |
snapshot(boolean snapshot) |
Sets the snapshot.
|
FindOperation<T> |
sort(BsonDocument sort) |
Sets the sort criteria to apply to the query.
|
public FindOperation(MongoNamespace namespace, Decoder<T> decoder)
namespace
- the database and collection namespace for the operation.decoder
- the decoder for the result documents.public MongoNamespace getNamespace()
public Decoder<T> getDecoder()
public BsonDocument getFilter()
public FindOperation<T> filter(BsonDocument filter)
filter
- the filter, which may be null.public int getBatchSize()
public FindOperation<T> batchSize(int batchSize)
batchSize
- the batch sizepublic int getLimit()
public FindOperation<T> limit(int limit)
limit
- the limit, which may be nullpublic BsonDocument getModifiers()
@Deprecated public FindOperation<T> modifiers(BsonDocument modifiers)
modifiers
- the query modifiers to apply, which may be null.public BsonDocument getProjection()
public FindOperation<T> projection(BsonDocument projection)
projection
- the project document, which may be null.public long getMaxTime(TimeUnit timeUnit)
timeUnit
- the time unit to return the result inpublic FindOperation<T> maxTime(long maxTime, TimeUnit timeUnit)
maxTime
- the max timetimeUnit
- the time unit, which may not be nullpublic long getMaxAwaitTime(TimeUnit timeUnit)
timeUnit
- the time unit to return the result inpublic FindOperation<T> maxAwaitTime(long maxAwaitTime, TimeUnit timeUnit)
maxAwaitTime
- the max await time. A zero value will be ignored, and indicates that the driver should respect the server's
default valuetimeUnit
- the time unit, which may not be nullpublic int getSkip()
public FindOperation<T> skip(int skip)
skip
- the number of documents to skippublic BsonDocument getSort()
public FindOperation<T> sort(BsonDocument sort)
sort
- the sort criteria, which may be null.public CursorType getCursorType()
public FindOperation<T> cursorType(CursorType cursorType)
cursorType
- the cursor typepublic boolean isSlaveOk()
public FindOperation<T> slaveOk(boolean slaveOk)
slaveOk
- true if allowed to query non-primary replica set members.public boolean isOplogReplay()
public FindOperation<T> oplogReplay(boolean oplogReplay)
oplogReplay
- the oplogReplay valuepublic boolean isNoCursorTimeout()
The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use.
public FindOperation<T> noCursorTimeout(boolean noCursorTimeout)
noCursorTimeout
- true if the cursor timeout should be turned off.public boolean isPartial()
public FindOperation<T> partial(boolean partial)
partial
- allow partial results from a mongos if some shards are downpublic ReadConcern getReadConcern()
public FindOperation<T> readConcern(ReadConcern readConcern)
readConcern
- the read concernpublic Collation getCollation()
public FindOperation<T> collation(Collation collation)
A null value represents the server default.
collation
- the collation options to usepublic String getComment()
public FindOperation<T> comment(String comment)
comment
- the commentpublic BsonDocument getHint()
public FindOperation<T> hint(BsonDocument hint)
hint
- the hintpublic BsonDocument getMax()
public FindOperation<T> max(BsonDocument max)
max
- the maxpublic BsonDocument getMin()
public FindOperation<T> min(BsonDocument min)
min
- the minpublic long getMaxScan()
public FindOperation<T> maxScan(long maxScan)
maxScan
- the maxScanpublic boolean isReturnKey()
public FindOperation<T> returnKey(boolean returnKey)
returnKey
- the returnKeypublic boolean isShowRecordId()
public FindOperation<T> showRecordId(boolean showRecordId)
$recordId
to the returned documents.showRecordId
- the showRecordIdpublic boolean isSnapshot()
public FindOperation<T> snapshot(boolean snapshot)
snapshot
- the snapshotpublic BatchCursor<T> execute(ReadBinding binding)
ReadOperation
execute
in interface ReadOperation<T>
binding
- the binding to execute in the context ofpublic void executeAsync(AsyncReadBinding binding, SingleResultCallback<AsyncBatchCursor<T>> callback)
AsyncReadOperation
executeAsync
in interface AsyncReadOperation<T>
binding
- the binding to execute in the context ofcallback
- the callback to be called when the operation has been executedpublic ReadOperation<BsonDocument> asExplainableOperation(ExplainVerbosity explainVerbosity)
explainVerbosity
- the explain verbositypublic AsyncReadOperation<BsonDocument> asExplainableOperationAsync(ExplainVerbosity explainVerbosity)
explainVerbosity
- the explain verbosity