T
- the operations result type.public class FindAndUpdateOperation<T> extends BaseFindAndModifyOperation<T>
Modifier and Type | Field and Description |
---|---|
private java.util.List<BsonDocument> |
arrayFilters |
private java.lang.Boolean |
bypassDocumentValidation |
private Collation |
collation |
private Decoder<T> |
decoder |
private BsonDocument |
filter |
private long |
maxTimeMS |
private MongoNamespace |
namespace |
private BsonDocument |
projection |
private boolean |
retryWrites |
private boolean |
returnOriginal |
private BsonDocument |
sort |
private BsonDocument |
update |
private boolean |
upsert |
private WriteConcern |
writeConcern |
Constructor and Description |
---|
FindAndUpdateOperation(MongoNamespace namespace,
Decoder<T> decoder,
BsonDocument update)
Deprecated.
|
FindAndUpdateOperation(MongoNamespace namespace,
WriteConcern writeConcern,
boolean retryWrites,
Decoder<T> decoder,
BsonDocument update)
Construct a new instance.
|
FindAndUpdateOperation(MongoNamespace namespace,
WriteConcern writeConcern,
Decoder<T> decoder,
BsonDocument update)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
FindAndUpdateOperation<T> |
arrayFilters(java.util.List<BsonDocument> arrayFilters)
Sets the array filters option
|
FindAndUpdateOperation<T> |
bypassDocumentValidation(java.lang.Boolean bypassDocumentValidation)
Sets the bypass document level validation flag.
|
FindAndUpdateOperation<T> |
collation(Collation collation)
Sets the collation options
|
FindAndUpdateOperation<T> |
filter(BsonDocument filter)
Sets the filter to apply to the query.
|
java.util.List<BsonDocument> |
getArrayFilters()
Returns the array filters option
|
java.lang.Boolean |
getBypassDocumentValidation()
Gets the bypass document level validation flag
|
Collation |
getCollation()
Returns the collation options
|
protected CommandOperationHelper.CommandCreator |
getCommandCreator(SessionContext sessionContext) |
protected java.lang.String |
getDatabaseName() |
Decoder<T> |
getDecoder()
Gets the decoder used to decode the result documents.
|
protected FieldNameValidator |
getFieldNameValidator() |
BsonDocument |
getFilter()
Gets the query filter.
|
long |
getMaxTime(java.util.concurrent.TimeUnit timeUnit)
Gets the maximum execution time on the server for this operation.
|
MongoNamespace |
getNamespace()
Gets the namespace.
|
BsonDocument |
getProjection()
Gets a document describing the fields to return for all matching documents.
|
BsonDocument |
getSort()
Gets the sort criteria to apply to the query.
|
BsonDocument |
getUpdate()
Gets the document containing update operators
|
WriteConcern |
getWriteConcern()
Get the write concern for this operation
|
boolean |
isReturnOriginal()
When false, returns the updated document rather than the original.
|
boolean |
isUpsert()
Returns true if a new document should be inserted if there are no matches to the query filter.
|
FindAndUpdateOperation<T> |
maxTime(long maxTime,
java.util.concurrent.TimeUnit timeUnit)
Sets the maximum execution time on the server for this operation.
|
FindAndUpdateOperation<T> |
projection(BsonDocument projection)
Sets a document describing the fields to return for all matching documents.
|
FindAndUpdateOperation<T> |
returnOriginal(boolean returnOriginal)
Set to false if the updated document rather than the original should be returned.
|
FindAndUpdateOperation<T> |
sort(BsonDocument sort)
Sets the sort criteria to apply to the query.
|
FindAndUpdateOperation<T> |
upsert(boolean upsert)
Set to true if a new document should be inserted if there are no matches to the query filter.
|
execute, executeAsync
private final MongoNamespace namespace
private final BsonDocument update
private final WriteConcern writeConcern
private final boolean retryWrites
private BsonDocument filter
private BsonDocument projection
private BsonDocument sort
private long maxTimeMS
private boolean returnOriginal
private boolean upsert
private java.lang.Boolean bypassDocumentValidation
private Collation collation
private java.util.List<BsonDocument> arrayFilters
@Deprecated public FindAndUpdateOperation(MongoNamespace namespace, Decoder<T> decoder, BsonDocument update)
FindAndUpdateOperation(MongoNamespace, WriteConcern, boolean, Decoder, BsonDocument)
insteadnamespace
- the database and collection namespace for the operation.decoder
- the decoder for the result documents.update
- the document containing update operators.@Deprecated public FindAndUpdateOperation(MongoNamespace namespace, WriteConcern writeConcern, Decoder<T> decoder, BsonDocument update)
FindAndUpdateOperation(MongoNamespace, WriteConcern, boolean, Decoder, BsonDocument)
insteadnamespace
- the database and collection namespace for the operation.writeConcern
- the writeConcern for the operationdecoder
- the decoder for the result documents.update
- the document containing update operators.public FindAndUpdateOperation(MongoNamespace namespace, WriteConcern writeConcern, boolean retryWrites, Decoder<T> decoder, BsonDocument update)
namespace
- the database and collection namespace for the operation.writeConcern
- the writeConcern for the operationretryWrites
- if writes should be retried if they fail due to a network error.decoder
- the decoder for the result documents.update
- the document containing update operators.public MongoNamespace getNamespace()
public WriteConcern getWriteConcern()
WriteConcern
public Decoder<T> getDecoder()
getDecoder
in class BaseFindAndModifyOperation<T>
public BsonDocument getUpdate()
public BsonDocument getFilter()
public FindAndUpdateOperation<T> filter(BsonDocument filter)
filter
- the filter, which may be null.public BsonDocument getProjection()
public FindAndUpdateOperation<T> projection(BsonDocument projection)
projection
- the project document, which may be null.public long getMaxTime(java.util.concurrent.TimeUnit timeUnit)
timeUnit
- the time unit to return the result inpublic FindAndUpdateOperation<T> maxTime(long maxTime, java.util.concurrent.TimeUnit timeUnit)
maxTime
- the max timetimeUnit
- the time unit, which may not be nullpublic BsonDocument getSort()
public FindAndUpdateOperation<T> sort(BsonDocument sort)
sort
- the sort criteria, which may be null.public boolean isReturnOriginal()
public FindAndUpdateOperation<T> returnOriginal(boolean returnOriginal)
returnOriginal
- set to false if the updated document rather than the original should be returnedpublic boolean isUpsert()
public FindAndUpdateOperation<T> upsert(boolean upsert)
upsert
- true if a new document should be inserted if there are no matches to the query filterpublic java.lang.Boolean getBypassDocumentValidation()
public FindAndUpdateOperation<T> bypassDocumentValidation(java.lang.Boolean bypassDocumentValidation)
Note: This only applies when an $out stage is specified
.bypassDocumentValidation
- If true, allows the write to opt-out of document level validation.public Collation getCollation()
public FindAndUpdateOperation<T> collation(Collation collation)
A null value represents the server default.
collation
- the collation options to usepublic FindAndUpdateOperation<T> arrayFilters(java.util.List<BsonDocument> arrayFilters)
arrayFilters
- the array filters, which may be nullpublic java.util.List<BsonDocument> getArrayFilters()
protected java.lang.String getDatabaseName()
getDatabaseName
in class BaseFindAndModifyOperation<T>
protected FieldNameValidator getFieldNameValidator()
getFieldNameValidator
in class BaseFindAndModifyOperation<T>
protected CommandOperationHelper.CommandCreator getCommandCreator(SessionContext sessionContext)
getCommandCreator
in class BaseFindAndModifyOperation<T>