Click or drag to resize

MongoCollectionFindAndModify Method (IMongoQuery, IMongoSortBy, IMongoUpdate, Boolean, Boolean)

Note: This API is now obsolete.

Finds one matching document using the query and sortBy parameters and applies the specified update to it.

Namespace:  MongoDB.Driver
Assembly:  MongoDB.Driver.Legacy (in MongoDB.Driver.Legacy.dll) Version: 2.17.0+b316340e6cc3a8bfc8638dc31b54fbbfe41bfcb2
Syntax
[ObsoleteAttribute("Use the overload of FindAndModify that has a FindAndModifyArgs parameter instead.")]
public virtual FindAndModifyResult FindAndModify(
	IMongoQuery query,
	IMongoSortBy sortBy,
	IMongoUpdate update,
	bool returnNew,
	bool upsert
)

Parameters

query
Type: MongoDB.DriverIMongoQuery
The query (usually a QueryDocument or constructed using the Query builder).
sortBy
Type: MongoDB.DriverIMongoSortBy
The sort order to select one of the matching documents.
update
Type: MongoDB.DriverIMongoUpdate
The update to apply to the matching document.
returnNew
Type: SystemBoolean
Whether to return the new or old version of the modified document in the FindAndModifyResult.
upsert
Type: SystemBoolean
Whether to do an upsert if no matching document is found.

Return Value

Type: FindAndModifyResult
A FindAndModifyResult.
See Also