Table of Contents

Method FindAndModify

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.Legacy.dll

FindAndModify(IMongoQuery, IMongoSortBy, IMongoUpdate)

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

[Obsolete("Use the overload of FindAndModify that has a FindAndModifyArgs parameter instead.")]
public virtual FindAndModifyResult FindAndModify(IMongoQuery query, IMongoSortBy sortBy, IMongoUpdate update)

Parameters

query IMongoQuery

The query (usually a QueryDocument or constructed using the Query builder).

sortBy IMongoSortBy

The sort order to select one of the matching documents.

update IMongoUpdate

The update to apply to the matching document.

Returns

FindAndModifyResult

A FindAndModifyResult.

FindAndModify(IMongoQuery, IMongoSortBy, IMongoUpdate, bool)

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

[Obsolete("Use the overload of FindAndModify that has a FindAndModifyArgs parameter instead.")]
public virtual FindAndModifyResult FindAndModify(IMongoQuery query, IMongoSortBy sortBy, IMongoUpdate update, bool returnNew)

Parameters

query IMongoQuery

The query (usually a QueryDocument or constructed using the Query builder).

sortBy IMongoSortBy

The sort order to select one of the matching documents.

update IMongoUpdate

The update to apply to the matching document.

returnNew bool

Whether to return the new or old version of the modified document in the FindAndModifyResult.

Returns

FindAndModifyResult

A FindAndModifyResult.

FindAndModify(IMongoQuery, IMongoSortBy, IMongoUpdate, bool, bool)

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

[Obsolete("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 IMongoQuery

The query (usually a QueryDocument or constructed using the Query builder).

sortBy IMongoSortBy

The sort order to select one of the matching documents.

update IMongoUpdate

The update to apply to the matching document.

returnNew bool

Whether to return the new or old version of the modified document in the FindAndModifyResult.

upsert bool

Whether to do an upsert if no matching document is found.

Returns

FindAndModifyResult

A FindAndModifyResult.

FindAndModify(IMongoQuery, IMongoSortBy, IMongoUpdate, IMongoFields, bool, bool)

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

[Obsolete("Use the overload of FindAndModify that has a FindAndModifyArgs parameter instead.")]
public virtual FindAndModifyResult FindAndModify(IMongoQuery query, IMongoSortBy sortBy, IMongoUpdate update, IMongoFields fields, bool returnNew, bool upsert)

Parameters

query IMongoQuery

The query (usually a QueryDocument or constructed using the Query builder).

sortBy IMongoSortBy

The sort order to select one of the matching documents.

update IMongoUpdate

The update to apply to the matching document.

fields IMongoFields

Which fields of the modified document to return in the FindAndModifyResult.

returnNew bool

Whether to return the new or old version of the modified document in the FindAndModifyResult.

upsert bool

Whether to do an upsert if no matching document is found.

Returns

FindAndModifyResult

A FindAndModifyResult.

FindAndModify(FindAndModifyArgs)

Finds one matching document using the supplied arguments and applies the specified update to it.

public virtual FindAndModifyResult FindAndModify(FindAndModifyArgs args)

Parameters

args FindAndModifyArgs

The args.

Returns

FindAndModifyResult

A FindAndModifyResult.