update method
Future<Map<String, dynamic> >
update(
- dynamic selector,
- dynamic document, {
- bool upsert = false,
- bool multiUpdate = false,
- WriteConcern? writeConcern,
Modifies an existing document or documents in a collection.
The method can modify specific fields of an existing document or
documents or replace an existing document entirely,
depending on the document
parameter.
By default, the update()
method updates a single document.
Include the option multiUpdate: true to update all documents that match
the query criteria.
Implementation
Future<Map<String, dynamic>> update(selector, document,
{bool upsert = false,
bool multiUpdate = false,
WriteConcern? writeConcern}) async {
if (db._masterConnectionVerified.serverCapabilities.supportsOpMsg) {
await modernUpdate(selector, document,
upsert: upsert, multi: multiUpdate, writeConcern: writeConcern);
return db._getAcknowledgement();
}
return legacyUpdate(selector, document,
upsert: upsert, multiUpdate: multiUpdate, writeConcern: writeConcern);
}