FireDAC.Phys.MongoDBWrapper.TMongoCollection.Update
Delphi
procedure Update(AUpdate: TMongoUpdate; AFlags: TUpdateFlags = [TUpdateFlag.MultiUpdate]); overload;
function Update(AFlags: TUpdateFlags = [TUpdateFlag.MultiUpdate]): TMongoUpdate; overload;
C++
void __fastcall Update(TMongoUpdate* AUpdate, TUpdateFlags AFlags = (TUpdateFlags() << TUpdateFlag::MultiUpdate ))/* overload */;
TMongoUpdate* __fastcall Update(TUpdateFlags AFlags = (TUpdateFlags() << TUpdateFlag::MultiUpdate ))/* overload */;
Contents
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
procedure function |
public | FireDAC.Phys.MongoDBWrapper.pas FireDAC.Phys.MongoDBWrapper.hpp |
FireDAC.Phys.MongoDBWrapper | TMongoCollection |
Description
Executes the specified update builder on the collection.
Update supports two different coding styles.
You can optionally specify a set of update flags.
If the update operation succeeds, you can obtain the number of updated documents from the DocsModified and DocsUpserted properties.
If the update operation fails, it raises an exception.
Example
The following example changes the cuisine of Italian restaurants to "Mediterranean".
MongDB shell:
db.restaurants.update(
{ cuisine: "Italian" },
{ $set: { cuisine: "Mediterranean" } },
{ multi: true }
)
Delphi:
MyCollection.Update
.Match
.Add('cuisine', 'Italian')
.&End
.Modify
.&Set
.Field('cuisine', 'Mediterranean')
.&End
.&End
.Exec;
C++:
MyCollection->Update()
->Match()
->Add("cuisine", "Italian")
->End()
->Modify()
->Set()
->Field("cuisine", "Mediterranean")
->End()
->End()
->Exec();
See Also
- FireDAC.Phys.MongoDBWrapper.TMongoCollection.DocsMatched
- FireDAC.Phys.MongoDBWrapper.TMongoCollection.DocsModified
- FireDAC.Phys.MongoDBWrapper.TMongoCollection.DocsUpserted
- FireDAC.Phys.MongoDBWrapper.TMongoCollection.BeginBulk