Result class for an update operation.
- Full name:
\MongoDB\UpdateResult
private \MongoDB\Driver\WriteResult $writeResult
private bool $isAcknowledged
public __construct(\MongoDB\Driver\WriteResult $writeResult): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$writeResult |
\MongoDB\Driver\WriteResult |
Return the number of documents that were matched by the filter.
public getMatchedCount(): int
This method should only be called if the write was acknowledged.
See Also:
- \MongoDB\UpdateResult::isAcknowledged() -
Return the number of documents that were modified.
public getModifiedCount(): int|null
This value is undefined (i.e. null) if the write executed as a legacy operation instead of command.
This method should only be called if the write was acknowledged.
See Also:
- \MongoDB\UpdateResult::isAcknowledged() -
Return the number of documents that were upserted.
public getUpsertedCount(): int
This method should only be called if the write was acknowledged.
See Also:
- \MongoDB\UpdateResult::isAcknowledged() -
Return the ID of the document inserted by an upsert operation.
public getUpsertedId(): mixed|null
If the document had an ID prior to upserting (i.e. the server did not need to generate an ID), this will contain its "_id". Any server-generated ID will be a MongoDB\BSON\ObjectId instance.
This value is undefined (i.e. null) if an upsert did not take place.
This method should only be called if the write was acknowledged.
See Also:
- \MongoDB\UpdateResult::isAcknowledged() -
Return whether this update was acknowledged by the server.
public isAcknowledged(): bool
If the update was not acknowledged, other fields from the WriteResult (e.g. matchedCount) will be undefined and their getter methods should not be invoked.