Package io.realm.mongodb.mongo.options
Class FindOneAndModifyOptions
- java.lang.Object
-
- io.realm.mongodb.mongo.options.FindOneAndModifyOptions
-
public class FindOneAndModifyOptions extends Object
The options to apply to a findOneAndUpdate, findOneAndReplace, or findOneAndDelete operation (also commonly referred to as findOneAndModify operations).
-
-
Constructor Summary
Constructors Constructor Description FindOneAndModifyOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BsongetProjection()Gets a document describing the fields to return for all matching documents.BsongetSort()Gets the sort criteria to apply to the query.booleanisReturnNewDocument()Returns true if the findOneAndModify operation should return the new document.booleanisUpsert()Returns true if a new document should be inserted if there are no matches to the query filter.FindOneAndModifyOptionsprojection(Bson projection)Sets a document describing the fields to return for all matching documents.FindOneAndModifyOptionsreturnNewDocument(boolean returnNewDocument)Set to true if findOneAndModify operations should return the new updated document.FindOneAndModifyOptionssort(Bson sort)Sets the sort criteria to apply to the query.StringtoString()FindOneAndModifyOptionsupsert(boolean upsert)Set to true if a new document should be inserted if there are no matches to the query filter.
-
-
-
Method Detail
-
getProjection
@Nullable public Bson getProjection()
Gets a document describing the fields to return for all matching documents.- Returns:
- the project document, which may be null
-
projection
public FindOneAndModifyOptions projection(@Nullable Bson projection)
Sets a document describing the fields to return for all matching documents.- Parameters:
projection- the project document, which may be null.- Returns:
- this
-
getSort
@Nullable public Bson getSort()
Gets the sort criteria to apply to the query. The default is null, which means that the documents will be returned in an undefined order.- Returns:
- a document describing the sort criteria
-
sort
public FindOneAndModifyOptions sort(@Nullable Bson sort)
Sets the sort criteria to apply to the query.- Parameters:
sort- the sort criteria, which may be null.- Returns:
- this
-
isUpsert
public boolean isUpsert()
Returns true if a new document should be inserted if there are no matches to the query filter. The default is false. Note: Only findOneAndUpdate and findOneAndReplace take this option- Returns:
- true if a new document should be inserted if there are no matches to the query filter
-
upsert
public FindOneAndModifyOptions upsert(boolean upsert)
Set to true if a new document should be inserted if there are no matches to the query filter.- Parameters:
upsert- true if a new document should be inserted if there are no matches to the query filter.- Returns:
- this
-
isReturnNewDocument
public boolean isReturnNewDocument()
Returns true if the findOneAndModify operation should return the new document. The default is false Note: Only findOneAndUpdate and findOneAndReplace take this options findOneAndDelete will always return the old document- Returns:
- true if findOneAndModify operation should return the new document
-
returnNewDocument
public FindOneAndModifyOptions returnNewDocument(boolean returnNewDocument)
Set to true if findOneAndModify operations should return the new updated document. Set to false / leave blank to have these operation return the document before the update. Note: Only findOneAndUpdate and findOneAndReplace take this options findOneAndDelete will always return the old document- Parameters:
returnNewDocument- true if findOneAndModify operations should return the updated document- Returns:
- this
-
-